Class: Peachy::CurrentMethodCall
- Inherits:
-
Object
- Object
- Peachy::CurrentMethodCall
- Extended by:
- MethodMask
- Includes:
- MyMetaClass, XmlNode
- Defined in:
- lib/peachy/current_method_call.rb
Instance Method Summary collapse
- #create_attribute ⇒ Object
- #create_method_for_attribute {|match| ... } ⇒ Object
- #create_method_for_child_or_content(matches) ⇒ Object
- #define_child(method_name, &block) ⇒ Object
- #define_child_array(matches) ⇒ Object
- #define_child_as(child) ⇒ Object
-
#initialize(proxy, method) ⇒ CurrentMethodCall
constructor
A new instance of CurrentMethodCall.
Methods included from Compatibility
Constructor Details
#initialize(proxy, method) ⇒ CurrentMethodCall
Returns a new instance of CurrentMethodCall.
6 7 8 9 |
# File 'lib/peachy/current_method_call.rb', line 6 def initialize proxy, method @method_name = method @proxy = proxy end |
Instance Method Details
#create_attribute ⇒ Object
17 18 19 |
# File 'lib/peachy/current_method_call.rb', line 17 def create_attribute create_method_for_attribute if @proxy.node.has_children_and_attributes? end |
#create_method_for_attribute {|match| ... } ⇒ Object
21 22 23 24 25 |
# File 'lib/peachy/current_method_call.rb', line 21 def create_method_for_attribute match = find_match_by_attributes yield match if block_given? define_child_as(match.content) unless match.nil? end |
#create_method_for_child_or_content(matches) ⇒ Object
11 12 13 14 15 |
# File 'lib/peachy/current_method_call.rb', line 11 def create_method_for_child_or_content matches return define_child_array(matches) if matches.size > 1 child = matches[0].create_from_element define_child_as(child) end |
#define_child(method_name, &block) ⇒ Object
39 40 41 42 |
# File 'lib/peachy/current_method_call.rb', line 39 def define_child method_name, &block @proxy.eval_on_singleton_class { define_method(method_name.to_sym, &block) } yield end |
#define_child_array(matches) ⇒ Object
31 32 33 |
# File 'lib/peachy/current_method_call.rb', line 31 def define_child_array matches define_child(@method_name) { return CurrentMethodCall.matches_to_array(matches) } end |
#define_child_as(child) ⇒ Object
35 36 37 |
# File 'lib/peachy/current_method_call.rb', line 35 def define_child_as child define_child(method_name) { return child } end |