Class: Confman::ConfSet

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, fields = {}) ⇒ ConfSet

Returns a new instance of ConfSet.



145
146
147
148
149
150
# File 'lib/confman/api.rb', line 145

def initialize(api, fields = {})
  @api = api
  fields.each do |k,v|
    self.send("#{k}=", v) if self.respond_to?("#{k}=")
  end
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



142
143
144
# File 'lib/confman/api.rb', line 142

def api
  @api
end

#conf_pairsObject

Returns the value of attribute conf_pairs.



143
144
145
# File 'lib/confman/api.rb', line 143

def conf_pairs
  @conf_pairs
end

#created_atObject

Returns the value of attribute created_at.



143
144
145
# File 'lib/confman/api.rb', line 143

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



143
144
145
# File 'lib/confman/api.rb', line 143

def id
  @id
end

#nameObject

Returns the value of attribute name.



143
144
145
# File 'lib/confman/api.rb', line 143

def name
  @name
end

#updated_atObject

Returns the value of attribute updated_at.



143
144
145
# File 'lib/confman/api.rb', line 143

def updated_at
  @updated_at
end

Instance Method Details

#as_jsonObject



160
161
162
163
164
165
166
167
168
# File 'lib/confman/api.rb', line 160

def as_json
  {
    :id => id,
    :name => name,
    :created_at => created_at,
    :updated_at => updated_at,
    :conf_pairs => conf_pairs
  }
end

#pairsObject



156
157
158
# File 'lib/confman/api.rb', line 156

def pairs
  Hash[conf_pairs.collect { |p| p.symbolize_keys!; [p[:name], p[:value]] }]
end

#to_jsonObject



170
171
172
# File 'lib/confman/api.rb', line 170

def to_json
  as_json.to_json
end

#update_pairs(pairs) ⇒ Object



152
153
154
# File 'lib/confman/api.rb', line 152

def update_pairs(pairs)
  results, response = api.request(:put, "confman/sets/#{id}/update_pairs", conf_pairs: pairs)
end