Class: NokoBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/noko_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overwrite = {}, noko_options = {}) ⇒ NokoBuilder

Returns a new instance of NokoBuilder.



8
9
10
11
12
13
14
# File 'lib/noko_builder.rb', line 8

def initialize(overwrite={}, noko_options={})
  @overwrite = overwrite
  @noko = Nokogiri::XML::Builder.new(noko_options) do |xml|
    @xml = xml
    yield self
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/noko_builder.rb', line 16

def method_missing(id, *args, &block)
  args = update_value(id, args)
  args = update_attributes(id, args)
  args = args.compact.reject(&:blank?)
  
  @xml.send(id, *args, &block) if args.present? || block.present?
end

Instance Attribute Details

#nokoObject (readonly)

Returns the value of attribute noko.



5
6
7
# File 'lib/noko_builder.rb', line 5

def noko
  @noko
end