Class: NokoBuilder
- Inherits:
-
Object
- Object
- NokoBuilder
- Defined in:
- lib/noko_builder.rb
Instance Attribute Summary collapse
-
#noko ⇒ Object
readonly
Returns the value of attribute noko.
Instance Method Summary collapse
-
#initialize(overwrite = {}, noko_options = {}) ⇒ NokoBuilder
constructor
A new instance of NokoBuilder.
- #method_missing(id, *args, &block) ⇒ Object
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={}, ={}) @overwrite = overwrite @noko = Nokogiri::XML::Builder.new() 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
#noko ⇒ Object (readonly)
Returns the value of attribute noko.
5 6 7 |
# File 'lib/noko_builder.rb', line 5 def noko @noko end |