Class: SBF::Client::FullFund

Inherits:
Fund show all
Defined in:
lib/stbaldricks/entities/fund.rb

Constant Summary

Constants inherited from TopLevelEntity

TopLevelEntity::DEFAULT_CLASS_ACTIONS, TopLevelEntity::DEFAULT_CRUD_ACTIONS, TopLevelEntity::DEFAULT_ENDPOINT, TopLevelEntity::DEFAULT_INSTANCE_ACTIONS

Constants inherited from BaseEntity

BaseEntity::ELSE

Instance Attribute Summary collapse

Attributes inherited from BaseEntity

#errors

Instance Method Summary collapse

Methods included from DonationRecipientConcern

#donation_recipient_url

Methods included from Entities::DefaultCacheable

included

Methods inherited from TopLevelEntity

_endpoint, action, actions, blacklist_action, class_action, define_endpoint, endpoint, #endpoint, instance_action

Methods included from Entities::Cacheable

#cache_id, included

Methods inherited from BaseEntity

allow_instantiation?, attr_accessor, attr_reader, attr_writer, collection_attributes, defined_attributes, #destroyed?, #dirty_data, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, #error, inherited, #initialize, #keys_hash, #model_name, multitype_attr_accessor, multitype_attr_reader, multitype_attr_writer, multitype_collection_attr_accessor, multitype_collection_attr_reader, multitype_collection_attr_writer, #not_provided_attributes, optional_attributes, #persisted?, #reload!, #reload_recursive, #rollback!, #to_json, #to_partial

Methods included from EntityResponseConcern

#add_errors, #data, #error?, #errors?, #errors_http_code=, #http_code, #success?

Constructor Details

This class inherits a constructor from SBF::Client::BaseEntity

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



74
75
76
# File 'lib/stbaldricks/entities/fund.rb', line 74

def description
  @description
end

#disabledObject

Returns the value of attribute disabled.



73
74
75
# File 'lib/stbaldricks/entities/fund.rb', line 73

def disabled
  @disabled
end

#display_nameObject (readonly)

Returns the value of attribute display_name.



71
72
73
# File 'lib/stbaldricks/entities/fund.rb', line 71

def display_name
  @display_name
end

#idObject

Returns the value of attribute id.



70
71
72
# File 'lib/stbaldricks/entities/fund.rb', line 70

def id
  @id
end

#kid_nameObject

Returns the value of attribute kid_name.



80
81
82
# File 'lib/stbaldricks/entities/fund.rb', line 80

def kid_name
  @kid_name
end

#nameObject

Returns the value of attribute name.



72
73
74
# File 'lib/stbaldricks/entities/fund.rb', line 72

def name
  @name
end

#offline_donation_formObject

Returns the value of attribute offline_donation_form.



81
82
83
# File 'lib/stbaldricks/entities/fund.rb', line 81

def offline_donation_form
  @offline_donation_form
end

#offline_donation_uuidObject

Returns the value of attribute offline_donation_uuid.



81
82
83
# File 'lib/stbaldricks/entities/fund.rb', line 81

def offline_donation_uuid
  @offline_donation_uuid
end

Instance Method Details

#to_hashObject



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/stbaldricks/entities/fund.rb', line 117

def to_hash
  hsh = super.to_hash
  return hsh if @totals_by_year.nil?

  hsh[:totals_by_year] = {}
  @totals_by_year.each do |year_total|
    hsh[:totals_by_year][year_total.year.to_s.to_sym] = year_total.to_hash
  end

  hsh
end

#totals_by_year=(value) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/stbaldricks/entities/fund.rb', line 105

def totals_by_year=(value)
  if value.nil? || value.empty?
    @totals_by_year = []
    return
  end

  totals_by_year_will_change!
  @totals_by_year = value.map do |k, v|
    SBF::Client::Fund::YearlyTotals.new(v.merge(year: k.to_s.to_i))
  end
end