Module: FatModelAuth::ModelHelpers

Defined in:
lib/fat_model_auth/model_helpers.rb

Instance Method Summary collapse

Instance Method Details

#allows(*params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fat_model_auth/model_helpers.rb', line 4

def allows(*params)
  if self.respond_to? :gate_keeper
    class_eval do
      self.gate_keeper.add_rules(params)
    end
  else
    class_eval do
      cattr_accessor :gate_keeper
      self.gate_keeper = FatModelAuth::GateKeeper.new(params)

      define_method "allows" do |user|
        self.gate_keeper.check(self, user)
      end
    end
  end
end