module Grant::Grantable::ClassMethods

Public Instance Methods

grant(*args, &blk) click to toggle source
# File lib/grant/grantable.rb, line 13
def grant(*args, &blk)
  unless self.included_modules.include?(InstanceMethods)
    include InstanceMethods
    include Grant::Status

    [:find, :create, :update, :destroy].each do |action|
      send :class_attribute, "grantor_#{action}".to_sym
      send "grantor_#{action}=".to_sym, Grant::Grantor.new(action) { false }
      send "#{action == :find ? 'after' : 'before'}_#{action}".to_sym, "grant_#{action}".to_sym
    end
  end

  Grant::Config.new(*args).actions.each do |action|
    send "grantor_#{action}=".to_sym, Grant::Grantor.new(action, &blk)
  end
end