Class: CollectionJSON::QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/collection-json/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ QueryBuilder

Returns a new instance of QueryBuilder.



82
83
84
# File 'lib/collection-json/builder.rb', line 82

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



80
81
82
# File 'lib/collection-json/builder.rb', line 80

def data
  @data
end

Instance Method Details

#add_data(name, value = '', prompt = '') ⇒ Object



86
87
88
89
90
91
# File 'lib/collection-json/builder.rb', line 86

def add_data(name, value = '', prompt = '')
  data << Data.from_hash({'name' => name}).tap do |data|
    data.merge!({'value' => value}) if value != ''
    data.merge!({'prompt' => prompt}) if prompt != ''
  end
end