Class: ShelbyArena::ApiObject

Inherits:
Object
  • Object
show all
Defined in:
lib/api/api_object.rb

Overview

This class is the base class for all ShelbyArena objects and is meant to be inherited.

Direct Known Subclasses

Address, Contribution, Family, Fund, Person, ShelbySession

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#error_messagesObject (readonly)

Returns the value of attribute error_messages.



9
10
11
# File 'lib/api/api_object.rb', line 9

def error_messages
  @error_messages
end

#marked_for_destructionObject (readonly)

Returns the value of attribute marked_for_destruction.



9
10
11
# File 'lib/api/api_object.rb', line 9

def marked_for_destruction
  @marked_for_destruction
end

Instance Method Details

#initialize_from_json_object(object_attributes) ⇒ Object

Initializes the current object from the JSON data that was loaded into the Hash

Parameters:

  • object_attributes

    A Hash of values to load into the current object.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/api/api_object.rb', line 14

def initialize_from_json_object(object_attributes)
  if object_attributes.is_a?( Hash )
    object_attributes.each do |key, value| 
      method_to_call = "#{ShelbyArena::attr_underscore(key)}="
      
      if respond_to?(method_to_call)
        self.send(method_to_call, value) 
      else
        # debugger
        # asdf=234
        # puts "Missing :=> ".red + method_to_call.to_s  # Show the missing methods
      end
    end
  end     
end