module Representable::Decorator::InheritModule

TODO: implement that just by calling ::property(name, options){include mod} on the inheriting representer.

Public Instance Methods

inherit_module!(parent) click to toggle source
Calls superclass method
# File lib/representable/decorator.rb, line 31
def inherit_module!(parent)
  inherited_attrs = parent.representable_attrs[:definitions].keys

  super # in Representable, calls representable_attrs.inherit!(parent.representable_attrs).
  # now, inline representers are still modules, which is wrong.
  manifest!(inherited_attrs)
end

Private Instance Methods

manifest!(names) click to toggle source

one level deep manifesting modules into Decorators.

# File lib/representable/decorator.rb, line 41
def manifest!(names)
  names.each do |name| # only definitions.
    definition = representable_attrs.get(name)
    next unless definition[:_inline] and mod = definition.representer_module # only inline representers.

    # here, we can include Decorator features.
    inline_representer = build_inline(nil, representable_attrs.features, definition.name, {}) {
      include mod
    } # the includer controls what "wraps" the module.

    definition.merge!(:extend => inline_representer)
  end
end