Class: FatModelAuth::GateKeeper::Checker
- Inherits:
-
Object
- Object
- FatModelAuth::GateKeeper::Checker
- Defined in:
- lib/fat_model_auth/gate_keeper.rb
Instance Method Summary collapse
-
#initialize(map, model, user) ⇒ Checker
constructor
A new instance of Checker.
- #method_missing(method, *_args) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
Constructor Details
#initialize(map, model, user) ⇒ Checker
Returns a new instance of Checker.
37 38 39 40 41 |
# File 'lib/fat_model_auth/gate_keeper.rb', line 37 def initialize(map, model, user) @map = map @model = model @user = user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/fat_model_auth/gate_keeper.rb', line 43 def method_missing(method, *_args) raise NoMethodError, "undefined method allows(user).#{method} for #{@model.inspect}" unless @map.key?(method) return false if @user.nil? @map[method].call(@model, @user) end |
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
51 52 53 |
# File 'lib/fat_model_auth/gate_keeper.rb', line 51 def respond_to_missing?(method, include_private = false) @map.key?(method) || super end |