:prefix, :suffix alias to_s name def initialize(object, *methods) opts = (methods.pop if Hash === methods.last) || {} @name, @object, @methods = "Injection(#{object})", object, methods @prefix, @suffix, @as = opts.values_at :prefix, :suffix, :as define_reader(as, object) define_delegators(object, methods) define_reflection end def extended(base) @object.injected(base) if @object.instance_eval { defined?(injected) } end def inspect @inspect ||= name.dup.tap do |name| name.insert(-2, " as: ##{as}") if as name.insert(-2, " methods: #{methods}") unless methods.empty? name.insert(-2, " format: #{affix('<method>')}") if prefix || suffix end end Monday, September 24, 12