Class: Cobble::Binding
- Inherits:
-
Object
- Object
- Cobble::Binding
- Defined in:
- lib/cobble/binding.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #attributes_for(names) ⇒ Object
- #execute(&block) ⇒ Object
- #fake(name, *args) ⇒ Object
-
#initialize(name, options = {}) ⇒ Binding
constructor
:nodoc:.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Binding
:nodoc:
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cobble/binding.rb', line 7 def initialize(name, = {}) # :nodoc: self.name = name self.type = :build self. = {} () self.attributes_for(name) attr_for = self..delete(:attributes_for) if attr_for self.attributes_for(attr_for) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cobble/binding.rb', line 36 def method_missing(sym, *args, &block) unless self.[sym] if block_given? self.[sym] = yield end end end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/cobble/binding.rb', line 3 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/cobble/binding.rb', line 5 def @options end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/cobble/binding.rb', line 4 def type @type end |
Instance Method Details
#attributes_for(names) ⇒ Object
30 31 32 33 34 |
# File 'lib/cobble/binding.rb', line 30 def attributes_for(names) [names].flatten.each do |name| self. = Cobble.attribs(name).dup.merge(self.) end end |
#execute(&block) ⇒ Object
25 26 27 28 |
# File 'lib/cobble/binding.rb', line 25 def execute(&block) instance_eval(&block) end |