Class: Ick::Bizarro
- Inherits:
-
Object
- Object
- Ick::Bizarro
- Defined in:
- lib/ick/bizarro.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.belongs_to(clazz) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ick/bizarro.rb', line 16 def self.belongs_to clazz method_name = self.underscore(self.name.split('::')[-1]) unless clazz.method_defined?(method_name) clazz.class_eval " def #{method_name}(*values,&proc) values = [self] if values.empty? if block_given? #{self.name}.instance.invoke(*values, &proc) else Invoker.new(values, #{self.name}) end end" end end |
Instance Method Details
#invoke(*values, &proc) ⇒ Object
8 9 10 |
# File 'lib/ick/bizarro.rb', line 8 def invoke(*values, &proc) invoke_wrapped(values, ArrayWrapper, nil, &proc) end |
#unwrap(wrapped, wrapper_class) ⇒ Object
12 13 14 |
# File 'lib/ick/bizarro.rb', line 12 def unwrap(wrapped, wrapper_class) wrapped.respond_to?(:__value__) ? wrapped.__value__.first : wrapped end |