Class: TheCity::Fund

Inherits:
ApiObject show all
Defined in:
lib/api/fund.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) ⇒ Fund

Constructor.

Parameters:

  • reader (optional) (defaults to: nil)

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



33
34
35
36
37
38
39
40
# File 'lib/api/fund.rb', line 33

def initialize(reader = nil)
  if reader.is_a?(FundReader)
    initialize_from_json_object(reader.load_feed) 
  elsif reader.is_a?(Hash)
    initialize_from_json_object(reader)
  end
  @writer_object = FundWriter
end

Class Method Details

.load_fund_by_id(fund_id) ⇒ Object

Loads the fund by the specified ID.

Returns a new TheCity::Fund object.

Parameters:

  • fund_id

    The ID of the fund to load.



23
24
25
26
# File 'lib/api/fund.rb', line 23

def self.load_fund_by_id(fund_id)
  fund_reader = FundReader.new(fund_id)
  self.new(fund_reader)
end