alternative access via
   user.can_create_event?
   or
   user.can_update_event?(@event)

 TODO: What do we do if something else wants to use method_missing?
420081
def method_missing(name, *args, &block)
      string_name = name.to_s

      if string_name =~ /can_(.+)\?/
        self.can?(name, *args)
      else
        super(name, *args, &block)
      end
    end
1184368
def can?(*args)
      event_name  = args.shift
      events_map.can_perform?(event_name, current, *args)
    end
1261569
def evaluate_action_permission(options)
      # the target is the @resource
      # (@event, @user, @page, whatever)
      # it must exist in order to perform a permission check
      # involving the object
      if options[:target]
        object = instance_variable_get("@#{options[:target]}")
        return options[:user].can?(options[:permission], object)
      else
        return options[:user].can?(options[:permission])
      end
    end
106727
def event=(new_val)
      return nil if new_val == @event
      raise JSS::InvalidDataError, 'Unknown webhook event' unless EVENTS.include? new_val
      @event = new_val
      @need_to_update = true
    end
158727
def _modify_event(self, event_name, method, func):
        
        if event_name not in self.ALL_EVENTS:
            raise TypeError(('event_name ("%s") can only be one of the '
                             'following: %s') % (event_name,
                                                 repr(self.ALL_EVENTS)))
        if not isinstance(func, collections.Callable):
            raise TypeError(('func must be callable to be added as an '
                             'observer.'))
        getattr(self._events[event_name], method)(func)
1274676
def updated(self, user, options):
        
        for comment in self.comments:
            created = dateutil.parser.parse(comment["created"]).date()
            try:
                if (comment["author"]["emailAddress"] == user.email and
                        created >= options.since.date and
                        created < options.until.date):
                    return True
            except KeyError:
                pass
        return False
234689
function() {
      var updateEventsIsArray = _.isArray(this.updateEvents);
      var updateEventsIsSingleValue = !updateEventsIsArray && (_.isObject(this.updateEvents) || _.isString(this.updateEvents));
      var updateEventsIsUndefined = _.isUndefined(this.updateEvents);
      var updateEventsIsValidType = updateEventsIsArray || updateEventsIsSingleValue || updateEventsIsUndefined;

      if (updateEventsIsSingleValue) {
        this.updateEvents = [this.updateEvents];
      }

      if (!updateEventsIsValidType) {
        throw new Error('Update events are not an array, string or object.  Please see parameters for examples of how to define updateEvents.  Configured UpdateEvents: ', this.updateEvents);
      }

      // Remove any random falsey values (mostly to get rid of undefined events).
      this.updateEvents = _.compact(this.updateEvents);
      _.each(this.updateEvents, this.__validUpdateEvent);
    }
793282
function event(eventName, callingFunction) {
        if (typeof eventName !== 'string') {
            self.showError(self.errCodes.DEVELOPER_ERR, callingFunction + " called without a string as the first argument");
            throw "developer error";
        }
        if (!allowedEvents[eventName]) {
            self.showError(self.errCodes.DEVELOPER_ERR, callingFunction + " called with a bad event name = " + eventName);
            throw "developer error";
        }
    }
210720
def event_happened(event_name, model)
      self.last_action = event_name
      self.last_updated_node = model
      self.updated_at = Time.zone.now
      self.save!
    end
1134701
def modify_event_view(request, id=None):
    
    event = get_object_or_404(Event, id=id)
    is_events_admin = request.user.has_admin_permission('events')

    if not is_events_admin:
        raise exceptions.PermissionDenied

    if request.method == "POST":
        if is_events_admin:
            form = AdminEventForm(data=request.POST, instance=event, all_groups=request.user.has_admin_permission('groups'))
        else:
            form = EventForm(data=request.POST, instance=event, all_groups=request.user.has_admin_permission('groups'))
        logger.debug(form)
        if form.is_valid():
            obj = form.save()
            # SAFE HTML
            obj.description = safe_html(obj.description)
            obj.save()
            messages.success(request, "Successfully modified event.")
            # return redirect("events")
        else:
            messages.error(request, "Error modifying event.")
    else:
        if is_events_admin:
            form = AdminEventForm(instance=event, all_groups=request.user.has_admin_permission('groups'))
        else:
            form = EventForm(instance=event, all_groups=request.user.has_admin_permission('groups'))
    context = {"form": form, "action": "modify", "action_title": "Modify", "id": id, "is_events_admin": is_events_admin}
    return render(request, "events/add_modify.html", context)
1152439
def on_event(event_handler = nil, &block)
      event_handler ||= block
      raise ArgumentError, "no event_handler provided" if event_handler.nil?
      @event_handler = event_handler
    end
172289
def _trigger_events(view_obj, events_map, additional_kw=None):
    
    if additional_kw is None:
        additional_kw = {}

    event_kwargs = _get_event_kwargs(view_obj)
    if event_kwargs is None:
        return

    event_kwargs.update(additional_kw)
    event_cls = _get_event_cls(view_obj, events_map)
    event = event_cls(**event_kwargs)
    view_obj.request.registry.notify(event)
    return event
1157373
def update
      if @resource.update(resource_params)
        redirect_to [main_app, @resource], notice: t('.notice', default: update_message)
      else
        render :edit
      end
    end
250693
def available_events
      state = current_state
      ret = {}
      while(state) do
        ret = state.class.specification.events.merge(ret)
        state = state.parent_state
      end
      ret
    end
1101156
def method_missing(method_name, *args, &block)
      _, event_name, callback_name = *method_name.to_s.match(/^(\w*?on_\w+?)_(\w+)$/)
      if callback_name && callback_names.include?(callback_name.to_sym)
        public_send(event_name, :"#{callback_name}", *args, &block)
      else
        super
      end
    end
807337
def permit_event(self, column=None, value=None, **kwargs):
        
        return self._resolve_call('PCS_PERMIT_EVENT', column, value, **kwargs)
1084231
def event(self, utype, **kw):
        '''
        
        '''
        d = {'utype': utype}
        d.update(kw)
        pygame.event.post(pygame.event.Event(METAEVENT, d))