Module: Shackles::HelperMethods::ClassMethods
- Defined in:
- lib/shackles/helper_methods.rb
Overview
see readme for example usage
Instance Method Summary collapse
- #shackle_class_method(method, opts) ⇒ Object
- #shackle_class_methods(*methods, opts) ⇒ Object
- #shackle_method(method, opts) ⇒ Object
- #shackle_methods(*methods, opts) ⇒ Object
Instance Method Details
#shackle_class_method(method, opts) ⇒ Object
15 16 17 |
# File 'lib/shackles/helper_methods.rb', line 15 def shackle_class_method(method, opts) self.singleton_class.shackle_method(method, opts) end |
#shackle_class_methods(*methods, opts) ⇒ Object
11 12 13 |
# File 'lib/shackles/helper_methods.rb', line 11 def shackle_class_methods(*methods, opts) methods.each { |m| shackle_class_method(m, opts) } end |
#shackle_method(method, opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/shackles/helper_methods.rb', line 23 def shackle_method(method, opts) @shackles_module ||= begin m = Module.new self.prepend m m end @shackles_module.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args) Shackles.activate(#{opts[:environment].inspect}) { super } end RUBY end |
#shackle_methods(*methods, opts) ⇒ Object
19 20 21 |
# File 'lib/shackles/helper_methods.rb', line 19 def shackle_methods(*methods, opts) methods.each { |m| shackle_method(m, opts) } end |