Class: SparkApi::Models::VowAccount

Inherits:
Base
  • Object
show all
Extended by:
Finders
Includes:
Concerns::Destroyable, Concerns::Savable
Defined in:
lib/spark_api/models/vow_account.rb

Constant Summary

Constants included from Paginate

Paginate::DEFAULT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Base

#attributes, #errors, #parent

Instance Method Summary collapse

Methods included from Finders

find, find_one, first, last

Methods included from Concerns::Savable

#create!, #params_for_save, #save, #save!, #update!, #update_attributes

Methods included from Concerns::Destroyable

#destroy, #destroy!, #destroyed?, included

Methods inherited from Base

#connection, connection, count, element_name, element_name=, first, get, #id, #load, #method_missing, #parse_id, path, #path, #persisted?, prefix, prefix=, #resource_pluralized, #resource_uri, #respond_to?, #to_param, #to_partial_path

Methods included from Paginate

#collect, #paginate, #per_page

Methods included from Dirty

#changed, #changed?, #changed_attributes, #changes, #dirty_attributes, #previous_changes

Constructor Details

#initialize(attributes = {}) ⇒ VowAccount

Returns a new instance of VowAccount.



10
11
12
# File 'lib/spark_api/models/vow_account.rb', line 10

def initialize(attributes={})
  super(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SparkApi::Models::Base

Instance Method Details

#change_password(new_password) ⇒ Object



28
29
30
31
32
# File 'lib/spark_api/models/vow_account.rb', line 28

def change_password(new_password)
  attribute_will_change! 'Password'
  @attributes['Password'] = new_password
  save
end

#change_setting(key, val) ⇒ Object



34
35
36
37
38
# File 'lib/spark_api/models/vow_account.rb', line 34

def change_setting(key, val)
  attribute_will_change! "Settings"
  @attributes['Settings'] = {} if @attributes['Settings'].nil? || @attributes['Settings'] != Hash
  @attributes['Settings'][key.to_s] = val
end

#disableObject



23
24
25
26
# File 'lib/spark_api/models/vow_account.rb', line 23

def disable
  change_setting :Enabled, 'false'
  save
end

#enableObject



18
19
20
21
# File 'lib/spark_api/models/vow_account.rb', line 18

def enable
  change_setting :Enabled, 'true'
  save
end

#enabled?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/spark_api/models/vow_account.rb', line 14

def enabled?
  (@attributes['Settings'].class == Hash) && @attributes['Settings']['Enabled'] == 'true'
end

#post_dataObject



40
# File 'lib/spark_api/models/vow_account.rb', line 40

def post_data; attributes end