Class: ZendeskAPI::Setting

Inherits:
UpdateResource show all
Defined in:
lib/zendesk_api/resources.rb

Instance Attribute Summary collapse

Attributes inherited from DataResource

#error, #error_message

Attributes inherited from Data

#association, #attributes, #errors, #response

Instance Method Summary collapse

Methods included from Update

included

Methods included from Save

#clear_associations, #save, #save!, #save_associations

Methods included from ResponseHandler

#handle_response

Methods included from Verbs

#any, #delete, #post, #put

Methods inherited from Data

#==, #id, inherited, #loaded_associations, #method_missing, namespace, new_from_response, resource_name, resource_path, #respond_to_missing?, singular_resource_name, subclasses, #to_json, #to_s

Methods included from Associations

included, #wrap_resource

Constructor Details

#initialize(client, attributes = {}) ⇒ Setting

Returns a new instance of Setting.



214
215
216
217
218
219
220
221
222
# File 'lib/zendesk_api/resources.rb', line 214

def initialize(client, attributes = {})
  # Try and find the root key
  @on = (attributes.keys.map(&:to_s) - %w{association options}).first

  # Make what's inside that key the root attributes
  attributes.merge!(attributes.delete(@on))

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZendeskAPI::Data

Instance Attribute Details

#onObject (readonly)

Returns the value of attribute on.



212
213
214
# File 'lib/zendesk_api/resources.rb', line 212

def on
  @on
end

Instance Method Details

#attributes_for_saveObject



232
233
234
# File 'lib/zendesk_api/resources.rb', line 232

def attributes_for_save
  { self.class.resource_name => { @on => attributes.changes } }
end

#new_record?Boolean

Returns:

  • (Boolean)


224
225
226
# File 'lib/zendesk_api/resources.rb', line 224

def new_record?
  false
end

#path(options = {}) ⇒ Object



228
229
230
# File 'lib/zendesk_api/resources.rb', line 228

def path(options = {})
  super(options.merge(:with_parent => true))
end