Module: Adorn::Delegate
- Included in:
- Presenter
- Defined in:
- lib/adorn/delegate.rb
Class Method Summary collapse
-
.extensions(m = Module.new, context = self, &block) ⇒ Module
Creates and anonymous module and passes the result of the given block back to the context, extending the named @object instance variable.
Class Method Details
.extensions(m = Module.new, context = self, &block) ⇒ Module
Creates and anonymous module and passes the result of the given block back to the context, extending the named @object instance variable. Provide an interface to append to Adorn::Cache during request
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/adorn/delegate.rb', line 16 def self.extensions(m=Module.new, context=self, &block) return unless block_given? m.instance_eval do extensions = block.call # destructure this to handle more options if extensions.has_key?(:with) mods = extensions[:with] include *mods end end context.instance_eval do define_method(:initialize) do |*args| obj, context, = args @object = obj @context = context @options = if @object.extend(m) end end end |