Sha256: cf640e74cb06c9c5616bb0d7d18c8249a272ac67828cb35bbe9b09b5f64be291

Contents?: true

Size: 568 Bytes

Versions: 7

Compression:

Stored size: 568 Bytes

Contents

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

    def self.prepare(represented)
      new(represented)
    end

    def self.inline_representer(base_module, &block) # DISCUSS: separate module?
      Class.new(self) do
        include base_module
        instance_exec &block
      end
    end

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

    def initialize(represented)
      @represented = represented
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
representable-1.7.4 lib/representable/decorator.rb
representable-1.7.3 lib/representable/decorator.rb
representable-1.7.2 lib/representable/decorator.rb
representable-1.7.1 lib/representable/decorator.rb
representable-1.7.0 lib/representable/decorator.rb
representable-1.6.1 lib/representable/decorator.rb
representable-1.6.0 lib/representable/decorator.rb