Sha256: ba1b8e218103d4a57a77d733306484ddef53f8c038b22bfad135452f846fb487

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

require "representable"
require "uber/inheritable_attr"

module Representable
  class Decorator
    attr_reader :represented
    alias_method :decorated, :represented

    # TODO: when moving all class methods into ClassMethods, i get a segfault.
    def self.prepare(represented)
      new(represented)
    end

    def self.default_nested_class #FIXME. SHOULD we move that into NestedBuilder?
      Representable::Decorator
    end

    # extend ::Declarative::Heritage::Inherited # DISCUSS: currently, that is handled via Representable::inherited.

    # This is called from inheritable_attr when inheriting a decorator class to a subclass.
    # Explicitly subclassing the Decorator makes sure representable_attrs is a clean version.
    def self.clone
      Class.new(self)
    end

    include Representable # include after class methods so Decorator::prepare can't be overwritten by Representable::prepare.
    include Cached

    extend Uber::InheritableAttr
    inheritable_attr :map
    self.map = Binding::Map.new

    def initialize(represented)
      @represented = represented
    end

    def self.nested_builder
      ::Declarative::Schema::DSL::NestedBuilder
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
representable-3.0.4 lib/representable/decorator.rb
representable-3.0.3 lib/representable/decorator.rb
representable-3.0.2 lib/representable/decorator.rb
representable-3.0.1 lib/representable/decorator.rb
representable-3.0.0 lib/representable/decorator.rb
representable-2.4.1 lib/representable/decorator.rb
representable-2.4.0 lib/representable/decorator.rb
representable-2.4.0.rc5 lib/representable/decorator.rb
representable-2.4.0.rc4 lib/representable/decorator.rb
representable-2.4.0.rc3 lib/representable/decorator.rb
representable-2.4.0.rc2 lib/representable/decorator.rb
representable-2.4.0.rc1 lib/representable/decorator.rb