Module: Petergate::ControllerMethods::ClassMethods
- Defined in:
- lib/petergate.rb
Instance Method Summary collapse
- #access(rules = {}, &block) ⇒ Object
- #all_actions ⇒ Object
- #const_missing(const_name) ⇒ Object
- #except_actions(arr = []) ⇒ Object
Instance Method Details
#access(rules = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/petergate.rb', line 24 def access(rules = {}, &block) if block b_rules = block.call rules = rules.merge(b_rules) if b_rules.is_a?(Hash) end instance_eval do @_controller_rules = rules def controller_rules @_controller_rules end end class_eval do def check_access (self.class.controller_rules) end end end |
#all_actions ⇒ Object
16 17 18 |
# File 'lib/petergate.rb', line 16 def all_actions ->{self.action_methods.to_a.map(&:to_sym) - [:check_access, :title]} end |
#const_missing(const_name) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/petergate.rb', line 7 def const_missing(const_name) if [:AllRest, :ALLREST].include?(const_name) warn "`AllRest` and `ALLREST` has been deprecated. Use :all instead." return ALLRESTDEP else return super end end |
#except_actions(arr = []) ⇒ Object
20 21 22 |
# File 'lib/petergate.rb', line 20 def except_actions(arr = []) ->{all_actions.call - arr} end |