Sha256: 554495c3556d4be961d3fa59836071098a46bbf9edfe597b418d24d803c8feb0
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
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) # FIXME: it is wrong to inherit from self here as we just want to "inherit" the included modules but nothing else. Class.new(self).tap do |decorator| decorator.class_eval do # Ruby 1.8.7 wouldn't properly execute the block passed to Class.new! # Remove parent's property definitions before defining the inline ones. #FIXME: don't inherit from self, remove those 2 lines. representable_attrs.clear representable_attrs.inheritable_arrays.clear include *base_module instance_exec &block end 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