Class: TheCity::Pledge

Inherits:
ApiObject show all
Defined in:
lib/api/pledge.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiObject

__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes

Constructor Details

#initialize(reader = nil) ⇒ Pledge

Constructor.

Parameters:

  • reader (optional) (defaults to: nil)

    The object that has the data. This can be a TheCity::PledgeReader or Hash object.



37
38
39
40
41
42
43
# File 'lib/api/pledge.rb', line 37

def initialize(reader = nil)
  if reader.is_a?(PledgeReader)
    initialize_from_json_object(reader.load_feed) 
  elsif reader.is_a?(Hash)
    initialize_from_json_object(reader)
  end
end

Class Method Details

.load_pledge_by_id(pledge_id) ⇒ Object

Loads the pledge by the specified ID.

Returns a new TheCity::Pledge object.

Parameters:

  • pledge_id

    The ID of the pledge to load.



27
28
29
30
# File 'lib/api/pledge.rb', line 27

def self.load_pledge_by_id(pledge_id)
  pledge_reader = PledgeReader.new(Pledge_id)
  self.new(pledge_reader)
end