Class: AdfBuilder::Nodes::Prospect
- Inherits:
-
Node
- Object
- Node
- AdfBuilder::Nodes::Prospect
show all
- Defined in:
- lib/adf_builder/nodes/prospect.rb
Instance Attribute Summary
Attributes inherited from Node
#attributes, #children, #tag_name, #value
Instance Method Summary
collapse
Methods inherited from Node
#add_child, #initialize, #method_missing, #remove_children, #respond_to_missing?, #to_xml
included
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class AdfBuilder::Nodes::Node
Instance Method Details
#customer(&block) ⇒ Object
30
31
32
33
34
|
# File 'lib/adf_builder/nodes/prospect.rb', line 30
def customer(&block)
customer = Customer.new
customer.instance_eval(&block) if block_given?
add_child(customer)
end
|
#customers ⇒ Object
53
54
55
|
# File 'lib/adf_builder/nodes/prospect.rb', line 53
def customers
@children.select { |c| c.is_a?(Customer) }
end
|
#provider(&block) ⇒ Object
42
43
44
45
46
|
# File 'lib/adf_builder/nodes/prospect.rb', line 42
def provider(&block)
provider = Provider.new
provider.instance_eval(&block) if block_given?
add_child(provider)
end
|
#request_date(date) ⇒ Object
19
20
21
22
|
# File 'lib/adf_builder/nodes/prospect.rb', line 19
def request_date(date)
remove_children(:requestdate)
add_child(GenericNode.new(:requestdate, {}, date))
end
|
#validate! ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/adf_builder/nodes/prospect.rb', line 6
def validate!
super
unless @children.any? { |c| c.tag_name == :requestdate }
raise AdfBuilder::Error, "Prospect must have a requestdate"
end
unless @children.any? { |c| c.is_a?(Vehicle) }
raise AdfBuilder::Error, "Prospect must have at least one vehicle"
end
raise AdfBuilder::Error, "Prospect must have a customer" unless @children.any? { |c| c.is_a?(Customer) }
raise AdfBuilder::Error, "Prospect must have a vendor" unless @children.any? { |c| c.is_a?(Vendor) }
end
|
#vehicle(&block) ⇒ Object
24
25
26
27
28
|
# File 'lib/adf_builder/nodes/prospect.rb', line 24
def vehicle(&block)
vehicle = Vehicle.new
vehicle.instance_eval(&block) if block_given?
add_child(vehicle)
end
|
#vehicles ⇒ Object
49
50
51
|
# File 'lib/adf_builder/nodes/prospect.rb', line 49
def vehicles
@children.select { |c| c.is_a?(Vehicle) }
end
|
#vendor(&block) ⇒ Object
36
37
38
39
40
|
# File 'lib/adf_builder/nodes/prospect.rb', line 36
def vendor(&block)
vendor = Vendor.new
vendor.instance_eval(&block) if block_given?
add_child(vendor)
end
|