Sha256: 0953daa77e9995274795edf34d5e5b784a518d0a123cda8d69015ae77e0e31b8
Contents?: true
Size: 875 Bytes
Versions: 4
Compression:
Stored size: 875 Bytes
Contents
require 'delegate' module Sinatra module Decorator class Base < SimpleDelegator attr_reader :object def initialize(object, options = {}) @object = object @context = options[:context] super(object) end def to_model __getobj__ end def class to_model.class end def kind_of?(klass) to_model.kind_of?(klass) end alias_method :is_a?, :kind_of? def instance_of?(klass) to_model.instance_of?(klass) end def decorated? true end private def self.context(context) _helper_method_name = :h define_method(_helper_method_name) do @context || context.to_s.camelize.constantize.new! end private _helper_method_name end end # Base end # Decorator end # Sinatra
Version data entries
4 entries across 4 versions & 1 rubygems