Class: AdfBuilder::Provider
- Inherits:
-
Object
- Object
- AdfBuilder::Provider
- Defined in:
- lib/adf_builder/provider/provider.rb
Constant Summary collapse
- FREE_TEXT_OPTIONAL_TAGS =
[:service, :url]
Instance Method Summary collapse
- #add(name, params = {}) ⇒ Object
- #add_contact(name, opts = {}) ⇒ Object
- #add_email(email, params = {}) ⇒ Object
- #add_id(index, value, source = nil, sequence = 1) ⇒ Object
- #add_phone(phone, params = {}) ⇒ Object
- #contact ⇒ Object
-
#initialize(prospect) ⇒ Provider
constructor
A new instance of Provider.
- #update_tags_with_free_text(tags) ⇒ Object
Constructor Details
#initialize(prospect) ⇒ Provider
Returns a new instance of Provider.
7 8 9 10 11 |
# File 'lib/adf_builder/provider/provider.rb', line 7 def initialize(prospect) @prospect = prospect @provider = nil @contact = nil end |
Instance Method Details
#add(name, params = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/adf_builder/provider/provider.rb', line 18 def add(name, params={}) @provider = Ox::Element.new('provider') params.merge!({valid_values: AdfBuilder::Contact::VALID_VALUES, valid_parameters: AdfBuilder::Contact::VALID_PARAMETERS}) AdfBuilder::Builder.update_node(@provider, :name, name, params) @prospect << @provider end |
#add_contact(name, opts = {}) ⇒ Object
25 26 27 |
# File 'lib/adf_builder/provider/provider.rb', line 25 def add_contact(name, opts={}) @contact = Contact.new(@provider, name, opts) end |
#add_email(email, params = {}) ⇒ Object
34 35 36 37 |
# File 'lib/adf_builder/provider/provider.rb', line 34 def add_email(email, params={}) params.merge!({valid_values: AdfBuilder::Contact::VALID_VALUES, valid_parameters: AdfBuilder::Contact::VALID_PARAMETERS}) AdfBuilder::Builder.update_node(@provider, :email, email, params) end |
#add_id(index, value, source = nil, sequence = 1) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/adf_builder/provider/provider.rb', line 47 def add_id(index, value, source=nil, sequence=1) if @prospect.locate("provider").empty? false else Id.new.add(@prospect.provider(index), value, source, sequence) end end |
#add_phone(phone, params = {}) ⇒ Object
29 30 31 32 |
# File 'lib/adf_builder/provider/provider.rb', line 29 def add_phone(phone, params={}) params.merge!({valid_values: AdfBuilder::Contact::VALID_VALUES, valid_parameters: AdfBuilder::Contact::VALID_PARAMETERS}) AdfBuilder::Builder.update_node(@provider, :phone, phone, params) end |
#contact ⇒ Object
13 14 15 |
# File 'lib/adf_builder/provider/provider.rb', line 13 def contact @contact end |
#update_tags_with_free_text(tags) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/adf_builder/provider/provider.rb', line 39 def () .each do |key, value| if FREE_TEXT_OPTIONAL_TAGS.include? key.to_sym AdfBuilder::Builder.update_node(@provider, key, value) end end end |