Module: GuardRail::HelperMethods::ClassMethods
- Defined in:
- lib/guard_rail/helper_methods.rb
Overview
see readme for example usage
Instance Method Summary collapse
- #guard_rail_class_method(method, opts) ⇒ Object
- #guard_rail_class_methods(*methods, opts) ⇒ Object
- #guard_rail_method(method, opts) ⇒ Object
- #guard_rail_methods(*methods, opts) ⇒ Object
Instance Method Details
#guard_rail_class_method(method, opts) ⇒ Object
17 18 19 |
# File 'lib/guard_rail/helper_methods.rb', line 17 def guard_rail_class_method(method, opts) self.singleton_class.guard_rail_method(method, opts) end |
#guard_rail_class_methods(*methods, opts) ⇒ Object
13 14 15 |
# File 'lib/guard_rail/helper_methods.rb', line 13 def guard_rail_class_methods(*methods, opts) methods.each { |m| guard_rail_class_method(m, opts) } end |
#guard_rail_method(method, opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/guard_rail/helper_methods.rb', line 25 def guard_rail_method(method, opts) @guard_rail_module ||= begin m = Module.new self.prepend m m end @guard_rail_module.class_eval "def \#{method}(*args)\nGuardRail.activate(\#{opts[:environment].inspect}) { super }\nend\n", __FILE__, __LINE__ + 1 end |
#guard_rail_methods(*methods, opts) ⇒ Object
21 22 23 |
# File 'lib/guard_rail/helper_methods.rb', line 21 def guard_rail_methods(*methods, opts) methods.each { |m| guard_rail_method(m, opts) } end |