Module: Contextual::ClassMethods
- Defined in:
- lib/contextual.rb
Instance Method Summary collapse
Instance Method Details
#has_context(name, opts = {}) ⇒ Object
11 12 13 |
# File 'lib/contextual.rb', line 11 def has_context(name, opts={}) self.contexts[name] = [opts[:using]].flatten end |
#with_context(name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/contextual.rb', line 15 def with_context(name) value = new value.singleton_class.send(:attr_accessor, :context) modules = self.contexts[name] value.context = {name => modules} modules.each do |m| value.extend m end value end |