Class: Wrapper
- Defined in:
- lib/formula_eval/wrapper.rb,
lib/formula_eval/wrapper.rb
Overview
class Wrapper
attr_accessor :obj
include FromHash
def method_missing(sym,*args,&b)
obj.send(sym,*args,&b).to_wrapped
end
end
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new(obj) ⇒ Object
141 142 143 |
# File 'lib/formula_eval/wrapper.rb', line 141 def self.new(obj) new_inner(obj).tap { |x| mylog 'wrapper', :obj => obj, :wrapper_class => x.class } end |
.new_inner(obj) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/formula_eval/wrapper.rb', line 132 def self.new_inner(obj) if obj.kind_of?(Array) ArrayWrapper.new(:obj => obj) elsif obj.kind_of?(Hash) HashWrapper.new(:hash => obj) else obj end end |
.wrapped?(obj) ⇒ Boolean
144 145 146 |
# File 'lib/formula_eval/wrapper.rb', line 144 def self.wrapped?(obj) [ArrayWrapper,HashWrapper].any? { |cls| obj.kind_of?(cls) } end |
Instance Method Details
#respond_to?(sym) ⇒ Boolean
10 11 12 |
# File 'lib/formula_eval/wrapper.rb', line 10 def respond_to?(sym) obj.respond_to?(sym) end |