Class: Confman::ConfSet
- Inherits:
-
Object
- Object
- Confman::ConfSet
- Defined in:
- lib/confman/api.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#conf_pairs ⇒ Object
Returns the value of attribute conf_pairs.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(api, fields = {}) ⇒ ConfSet
constructor
A new instance of ConfSet.
- #pairs ⇒ Object
- #to_json ⇒ Object
- #update_pairs(pairs) ⇒ Object
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
#api ⇒ Object (readonly)
Returns the value of attribute api.
142 143 144 |
# File 'lib/confman/api.rb', line 142 def api @api end |
#conf_pairs ⇒ Object
Returns the value of attribute conf_pairs.
143 144 145 |
# File 'lib/confman/api.rb', line 143 def conf_pairs @conf_pairs end |
#created_at ⇒ Object
Returns the value of attribute created_at.
143 144 145 |
# File 'lib/confman/api.rb', line 143 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
143 144 145 |
# File 'lib/confman/api.rb', line 143 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
143 144 145 |
# File 'lib/confman/api.rb', line 143 def name @name end |
#updated_at ⇒ Object
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_json ⇒ Object
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 |
#pairs ⇒ Object
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_json ⇒ Object
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 |