Class: Seam::Resources::BaseResource
- Inherits:
-
Object
- Object
- Seam::Resources::BaseResource
- Defined in:
- lib/seam/base_resource.rb
Direct Known Subclasses
AccessCode, AccessGrant, AccessMethod, AcsAccessGroup, AcsCredential, AcsCredentialPool, AcsCredentialProvisioningAutomation, AcsEncoder, AcsEntrance, AcsSystem, AcsUser, ActionAttempt, Batch, BridgeClientSession, BridgeConnectedSystems, ClientSession, ConnectWebview, ConnectedAccount, CustomizationProfile, Device, DeviceProvider, EnrollmentAutomation, InstantKey, MagicLink, NoiseThreshold, Pagination, Phone, PhoneRegistration, PhoneSession, ResourceError, ResourceWarning, SeamEvent, Space, StaffMember, ThermostatDailyProgram, ThermostatSchedule, UnmanagedAccessCode, UnmanagedAcsAccessGroup, UnmanagedAcsCredential, UnmanagedAcsUser, UnmanagedDevice, UserIdentity, Webhook, Workspace
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, client = nil) ⇒ BaseResource
constructor
A new instance of BaseResource.
- #inspect ⇒ Object
- #update_from_response(data) ⇒ Object
Constructor Details
#initialize(data, client = nil) ⇒ BaseResource
Returns a new instance of BaseResource.
11 12 13 14 15 |
# File 'lib/seam/base_resource.rb', line 11 def initialize(data, client = nil) @data = data @client = client process_data_attributes(@data) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/seam/base_resource.rb', line 9 def client @client end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/seam/base_resource.rb', line 9 def data @data end |
Class Method Details
.date_accessor(*attrs) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/seam/base_resource.rb', line 39 def self.date_accessor(*attrs) attrs.each do |attr| define_method(attr) do value = instance_variable_get(:"@#{attr}") value.nil? ? nil : parse_datetime(value) end end end |
.load_from_response(data, client = nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/seam/base_resource.rb', line 22 def self.load_from_response(data, client = nil) if data.is_a?(Array) data.map { |d| new(d, client) } else new(data, client) end end |
Instance Method Details
#inspect ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/seam/base_resource.rb', line 30 def inspect "<#{self.class.name}:#{"0x00%x" % (object_id << 1)}\n" + # rubocop:disable Style/StringConcatenation, Style/FormatString instance_variables .map { |k| k.to_s.sub("@", "") } .filter { |k| k != "data" and k != "client" and respond_to? k } .map { |k| " #{k}=#{send(k).inspect}" } .join("\n") + ">" end |
#update_from_response(data) ⇒ Object
17 18 19 20 |
# File 'lib/seam/base_resource.rb', line 17 def update_from_response(data) @data = data process_data_attributes(@data) end |