Class: Ohm::Model::Wrapper
- Inherits:
- Ohm::BasicObject
- Defined in:
- lib/ohm.rb
Overview
Wraps a model name for lazy evaluation.
Class Method Summary (collapse)
Instance Method Summary (collapse)
- - (Object) class
-
- (Wrapper) initialize(name, &block)
constructor
A new instance of Wrapper.
- - (Object) inspect
- - (Object) unwrap
Constructor Details
- (Wrapper) initialize(name, &block)
A new instance of Wrapper
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ohm.rb', line 68 def initialize(name, &block) @name = name @caller = ::Kernel.caller[2] @block = block class << self def method_missing(method_id, *args) ::Kernel.raise ::NoMethodError, "You tried to call #{@name}##{method_id}, but #{@name} is not defined on #{@caller}" end end end |
Class Method Details
+ (Object) wrap(object)
80 81 82 |
# File 'lib/ohm.rb', line 80 def self.wrap(object) object.class == self ? object : new(object.inspect) { object } end |