Sha256: 1a00e6a3c58f9d5c34cb08bbf21185004a73094cfb2b9066dc4d739a47919453

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 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, name, options, &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

1 entries across 1 versions & 1 rubygems

Version Path
representable-1.7.5 lib/representable/decorator.rb