Class: FinchAPI::BaseModel Abstract

Inherits:
Object
  • Object
show all
Extended by:
Converter
Defined in:
lib/finch-api/base_model.rb

Overview

This class is abstract.

Examples:

# `operation_support_matrix` is a `FinchAPI::Models::OperationSupportMatrix`
operation_support_matrix => {
  create: create,
  delete: delete,
  read: read
}

Direct Known Subclasses

Models::AccessTokenCreateParams, Models::AccountDisconnectParams, Models::AccountIntrospectParams, Models::AccountUpdateEvent::Data, Models::AccountUpdateEvent::Data::AuthenticationMethod, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company::Accounts, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company::Departments, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company::Departments::Parent, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company::Entity, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Company::Locations, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Directory, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Directory::Individuals, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Directory::Individuals::Manager, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Directory::Paging, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment::Department, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment::Employment, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment::Income, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment::Location, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Employment::Manager, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Individual, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Individual::Emails, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Individual::PhoneNumbers, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Individual::Residence, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayGroup, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::Paging, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::PayStatements, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::Earnings, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::EmployeeDeductions, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::EmployerContributions, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::Taxes, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Payment, Models::AccountUpdateEvent::Data::AuthenticationMethod::SupportedFields::Payment::PayPeriod, Models::BaseWebhookEvent, Models::Connect::SessionNewParams, Models::Connect::SessionNewParams::Integration, Models::Connect::SessionNewResponse, Models::Connect::SessionReauthenticateParams, Models::Connect::SessionReauthenticateResponse, Models::CreateAccessTokenResponse, Models::DirectoryEvent::Data, Models::DisconnectResponse, Models::EmploymentEvent::Data, Models::HRIS::BenefitContribution, Models::HRIS::BenefitCreateParams, Models::HRIS::BenefitFeaturesAndOperations, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures, Models::HRIS::BenefitListParams, Models::HRIS::BenefitListSupportedBenefitsParams, Models::HRIS::BenefitRetrieveParams, Models::HRIS::BenefitUpdateParams, Models::HRIS::Benefits::EnrolledIndividual, Models::HRIS::Benefits::EnrolledIndividual::Body, Models::HRIS::Benefits::IndividualBenefit, Models::HRIS::Benefits::IndividualBenefit::Body, Models::HRIS::Benefits::IndividualEnrollManyParams, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::CompanyContribution, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::EmployeeDeduction, Models::HRIS::Benefits::IndividualEnrolledIDsParams, Models::HRIS::Benefits::IndividualEnrolledIDsResponse, Models::HRIS::Benefits::IndividualRetrieveManyBenefitsParams, Models::HRIS::Benefits::IndividualUnenrollManyParams, Models::HRIS::Benefits::UnenrolledIndividual, Models::HRIS::Benefits::UnenrolledIndividual::Body, Models::HRIS::BenefitsSupport, Models::HRIS::CompanyBenefit, Models::HRIS::CompanyRetrieveParams, Models::HRIS::CreateCompanyBenefitsResponse, Models::HRIS::DirectoryListIndividualsParams, Models::HRIS::DirectoryListParams, Models::HRIS::DocumentListParams, Models::HRIS::DocumentListResponse, Models::HRIS::DocumentResponse, Models::HRIS::DocumentRetreiveParams, Models::HRIS::EmploymentData, Models::HRIS::EmploymentData::CustomField, Models::HRIS::EmploymentData::Department, Models::HRIS::EmploymentData::Employment, Models::HRIS::EmploymentData::Manager, Models::HRIS::EmploymentDataResponse, Models::HRIS::EmploymentRetrieveManyParams, Models::HRIS::EmploymentRetrieveManyParams::Request, Models::HRIS::HRISCompany, Models::HRIS::HRISCompany::Account, Models::HRIS::HRISCompany::Department, Models::HRIS::HRISCompany::Department::Parent, Models::HRIS::HRISCompany::Entity, Models::HRIS::Individual, Models::HRIS::Individual::Email, Models::HRIS::Individual::PhoneNumber, Models::HRIS::IndividualInDirectory, Models::HRIS::IndividualInDirectory::Department, Models::HRIS::IndividualInDirectory::Manager, Models::HRIS::IndividualResponse, Models::HRIS::IndividualRetrieveManyParams, Models::HRIS::IndividualRetrieveManyParams::Options, Models::HRIS::IndividualRetrieveManyParams::Request, Models::HRIS::PayStatement, Models::HRIS::PayStatement::Earning, Models::HRIS::PayStatement::Earning::Attributes, Models::HRIS::PayStatement::Earning::Attributes::Metadata, Models::HRIS::PayStatement::EmployeeDeduction, Models::HRIS::PayStatement::EmployeeDeduction::Attributes, Models::HRIS::PayStatement::EmployeeDeduction::Attributes::Metadata, Models::HRIS::PayStatement::EmployerContribution, Models::HRIS::PayStatement::EmployerContribution::Attributes, Models::HRIS::PayStatement::EmployerContribution::Attributes::Metadata, Models::HRIS::PayStatement::Tax, Models::HRIS::PayStatement::Tax::Attributes, Models::HRIS::PayStatement::Tax::Attributes::Metadata, Models::HRIS::PayStatementResponse, Models::HRIS::PayStatementResponseBody, Models::HRIS::PayStatementRetrieveManyParams, Models::HRIS::PayStatementRetrieveManyParams::Request, Models::HRIS::Payment, Models::HRIS::Payment::PayPeriod, Models::HRIS::PaymentListParams, Models::HRIS::SupportPerBenefitType, Models::HRIS::SupportedBenefit, Models::HRIS::UpdateCompanyBenefitResponse, Models::HRIS::W42005, Models::HRIS::W42005::Data, Models::HRIS::W42020, Models::HRIS::W42020::Data, Models::Income, Models::IndividualEvent::Data, Models::Introspection, Models::Introspection::AuthenticationMethod, Models::Introspection::AuthenticationMethod::ConnectionStatus, Models::Introspection::ConnectionStatus, Models::JobCompletionEvent::Data, Models::Jobs::AutomatedAsyncJob, Models::Jobs::AutomatedAsyncJob::Params, Models::Jobs::AutomatedCreateParams, Models::Jobs::AutomatedCreateParams::Params, Models::Jobs::AutomatedCreateResponse, Models::Jobs::AutomatedListParams, Models::Jobs::AutomatedListResponse, Models::Jobs::AutomatedListResponse::Meta, Models::Jobs::AutomatedListResponse::Meta::Quotas, Models::Jobs::AutomatedListResponse::Meta::Quotas::DataSyncAll, Models::Jobs::AutomatedRetrieveParams, Models::Jobs::ManualAsyncJob, Models::Jobs::ManualRetrieveParams, Models::Location, Models::Money, Models::OperationSupportMatrix, Models::Paging, Models::PayStatementEvent::Data, Models::PaymentEvent::Data, Models::Payroll::PayGroupListParams, Models::Payroll::PayGroupListResponse, Models::Payroll::PayGroupRetrieveParams, Models::Payroll::PayGroupRetrieveResponse, Models::Provider, Models::Provider::AuthenticationMethod, Models::Provider::AuthenticationMethod::SupportedFields, Models::Provider::AuthenticationMethod::SupportedFields::Company, Models::Provider::AuthenticationMethod::SupportedFields::Company::Accounts, Models::Provider::AuthenticationMethod::SupportedFields::Company::Departments, Models::Provider::AuthenticationMethod::SupportedFields::Company::Departments::Parent, Models::Provider::AuthenticationMethod::SupportedFields::Company::Entity, Models::Provider::AuthenticationMethod::SupportedFields::Company::Locations, Models::Provider::AuthenticationMethod::SupportedFields::Directory, Models::Provider::AuthenticationMethod::SupportedFields::Directory::Individuals, Models::Provider::AuthenticationMethod::SupportedFields::Directory::Individuals::Manager, Models::Provider::AuthenticationMethod::SupportedFields::Directory::Paging, Models::Provider::AuthenticationMethod::SupportedFields::Employment, Models::Provider::AuthenticationMethod::SupportedFields::Employment::Department, Models::Provider::AuthenticationMethod::SupportedFields::Employment::Employment, Models::Provider::AuthenticationMethod::SupportedFields::Employment::Income, Models::Provider::AuthenticationMethod::SupportedFields::Employment::Location, Models::Provider::AuthenticationMethod::SupportedFields::Employment::Manager, Models::Provider::AuthenticationMethod::SupportedFields::Individual, Models::Provider::AuthenticationMethod::SupportedFields::Individual::Emails, Models::Provider::AuthenticationMethod::SupportedFields::Individual::PhoneNumbers, Models::Provider::AuthenticationMethod::SupportedFields::Individual::Residence, Models::Provider::AuthenticationMethod::SupportedFields::PayGroup, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::Paging, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::PayStatements, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::Earnings, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::EmployeeDeductions, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::EmployerContributions, Models::Provider::AuthenticationMethod::SupportedFields::PayStatement::PayStatements::Taxes, Models::Provider::AuthenticationMethod::SupportedFields::Payment, Models::Provider::AuthenticationMethod::SupportedFields::Payment::PayPeriod, Models::ProviderListParams, Models::RequestForwardingForwardParams, Models::RequestForwardingForwardResponse, Models::RequestForwardingForwardResponse::Request, Models::Sandbox::CompanyUpdateParams, Models::Sandbox::CompanyUpdateParams::Account, Models::Sandbox::CompanyUpdateParams::Department, Models::Sandbox::CompanyUpdateParams::Department::Parent, Models::Sandbox::CompanyUpdateParams::Entity, Models::Sandbox::CompanyUpdateResponse, Models::Sandbox::CompanyUpdateResponse::Account, Models::Sandbox::CompanyUpdateResponse::Department, Models::Sandbox::CompanyUpdateResponse::Department::Parent, Models::Sandbox::CompanyUpdateResponse::Entity, Models::Sandbox::ConnectionCreateParams, Models::Sandbox::ConnectionCreateResponse, Models::Sandbox::Connections::AccountCreateParams, Models::Sandbox::Connections::AccountCreateResponse, Models::Sandbox::Connections::AccountUpdateParams, Models::Sandbox::Connections::AccountUpdateResponse, Models::Sandbox::DirectoryCreateParams, Models::Sandbox::DirectoryCreateParams::Body, Models::Sandbox::DirectoryCreateParams::Body::CustomField, Models::Sandbox::DirectoryCreateParams::Body::Department, Models::Sandbox::DirectoryCreateParams::Body::Email, Models::Sandbox::DirectoryCreateParams::Body::Employment, Models::Sandbox::DirectoryCreateParams::Body::Manager, Models::Sandbox::DirectoryCreateParams::Body::PhoneNumber, Models::Sandbox::EmploymentUpdateParams, Models::Sandbox::EmploymentUpdateParams::CustomField, Models::Sandbox::EmploymentUpdateParams::Department, Models::Sandbox::EmploymentUpdateParams::Employment, Models::Sandbox::EmploymentUpdateParams::Manager, Models::Sandbox::EmploymentUpdateResponse, Models::Sandbox::EmploymentUpdateResponse::CustomField, Models::Sandbox::EmploymentUpdateResponse::Department, Models::Sandbox::EmploymentUpdateResponse::Employment, Models::Sandbox::EmploymentUpdateResponse::Manager, Models::Sandbox::IndividualUpdateParams, Models::Sandbox::IndividualUpdateParams::Email, Models::Sandbox::IndividualUpdateParams::PhoneNumber, Models::Sandbox::IndividualUpdateResponse, Models::Sandbox::IndividualUpdateResponse::Email, Models::Sandbox::IndividualUpdateResponse::PhoneNumber, Models::Sandbox::JobCreateParams, Models::Sandbox::JobCreateResponse, Models::Sandbox::Jobs::ConfigurationRetrieveParams, Models::Sandbox::Jobs::SandboxJobConfiguration, Models::Sandbox::PaymentCreateParams, Models::Sandbox::PaymentCreateParams::PayStatement, Models::Sandbox::PaymentCreateParams::PayStatement::Earning, Models::Sandbox::PaymentCreateParams::PayStatement::Earning::Attributes, Models::Sandbox::PaymentCreateParams::PayStatement::Earning::Attributes::Metadata, Models::Sandbox::PaymentCreateParams::PayStatement::EmployeeDeduction, Models::Sandbox::PaymentCreateParams::PayStatement::EmployeeDeduction::Attributes, Models::Sandbox::PaymentCreateParams::PayStatement::EmployeeDeduction::Attributes::Metadata, Models::Sandbox::PaymentCreateParams::PayStatement::EmployerContribution, Models::Sandbox::PaymentCreateParams::PayStatement::EmployerContribution::Attributes, Models::Sandbox::PaymentCreateParams::PayStatement::EmployerContribution::Attributes::Metadata, Models::Sandbox::PaymentCreateParams::PayStatement::Tax, Models::Sandbox::PaymentCreateParams::PayStatement::Tax::Attributes, Models::Sandbox::PaymentCreateParams::PayStatement::Tax::Attributes::Metadata, Models::Sandbox::PaymentCreateResponse, RequestOptions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Converter

coerce, dump, type_info

Constructor Details

#initialize(data = {}) ⇒ BaseModel

Create a new instance of a model.

Parameters:



1155
1156
1157
1158
1159
1160
1161
1162
# File 'lib/finch-api/base_model.rb', line 1155

def initialize(data = {})
  case FinchAPI::Util.coerce_hash(data)
  in Hash => coerced
    @data = coerced
  else
    raise ArgumentError.new("Expected a #{Hash} or #{FinchAPI::BaseModel}, got #{data.inspect}")
  end
end

Class Method Details

.==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


988
# File 'lib/finch-api/base_model.rb', line 988

def ==(other) = other.is_a?(Class) && other <= FinchAPI::BaseModel && other.fields == fields

.coerce(value, state:) ⇒ FinchAPI::BaseModel, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (FinchAPI::BaseModel, Hash{Object=>Object}, Object)
  • state (Hash{Symbol=>Object})

    .

    @option state [Boolean, :strong] :strictness

    @option state [HashSymbol=>Object] :exactness

    @option state [Integer] :branched

Returns:



1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
# File 'lib/finch-api/base_model.rb', line 1010

def coerce(value, state:)
  exactness = state.fetch(:exactness)

  if value.is_a?(self.class)
    exactness[:yes] += 1
    return value
  end

  unless (val = FinchAPI::Util.coerce_hash(value)).is_a?(Hash)
    exactness[:no] += 1
    return value
  end
  exactness[:yes] += 1

  keys = val.keys.to_set
  instance = new
  data = instance.to_h

  fields.each do |name, field|
    mode, required, target = field.fetch_values(:mode, :required, :type)
    api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)

    unless val.key?(api_name)
      if const != FinchAPI::Util::OMIT
        exactness[:yes] += 1
      elsif required && mode != :dump
        exactness[nilable ? :maybe : :no] += 1
      else
        exactness[:yes] += 1
      end
      next
    end

    item = val.fetch(api_name)
    keys.delete(api_name)

    converted =
      if item.nil? && (nilable || !required)
        exactness[nilable ? :yes : :maybe] += 1
        nil
      else
        coerced = FinchAPI::Converter.coerce(target, item, state: state)
        case target
        in FinchAPI::Converter | Symbol
          coerced
        else
          item
        end
      end
    data.store(name, converted)
  end

  keys.each { data.store(_1, val.fetch(_1)) }
  instance
end

.dump(value) ⇒ Hash{Object=>Object}, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Hash{Object=>Object}, Object)


1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/finch-api/base_model.rb', line 1071

def dump(value)
  unless (coerced = FinchAPI::Util.coerce_hash(value)).is_a?(Hash)
    return super
  end

  acc = {}

  coerced.each do |key, val|
    name = key.is_a?(String) ? key.to_sym : key
    case (field = known_fields[name])
    in nil
      acc.store(name, super(val))
    else
      mode, api_name, type_fn = field.fetch_values(:mode, :api_name, :type_fn)
      case mode
      in :coerce
        next
      else
        target = type_fn.call
        acc.store(api_name, FinchAPI::Converter.dump(target, val))
      end
    end
  end

  known_fields.each_value do |field|
    mode, api_name, const = field.fetch_values(:mode, :api_name, :const)
    next if mode == :coerce || acc.key?(api_name) || const == FinchAPI::Util::OMIT
    acc.store(api_name, const)
  end

  acc
end

.fieldsHash{Symbol=>Hash{Symbol=>Object}}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash{Symbol=>Hash{Symbol=>Object}})


859
860
861
862
863
# File 'lib/finch-api/base_model.rb', line 859

def fields
  known_fields.transform_values do |field|
    {**field.except(:type_fn), type: field.fetch(:type_fn).call}
  end
end

.known_fieldsHash{Symbol=>Hash{Symbol=>Object}}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Assumes superclass fields are totally defined before fields are accessed /

defined on subclasses.

Returns:

  • (Hash{Symbol=>Hash{Symbol=>Object}})


852
853
854
# File 'lib/finch-api/base_model.rb', line 852

def known_fields
  @known_fields ||= (self < FinchAPI::BaseModel ? superclass.known_fields.dup : {})
end

.optional(name_sym, type_info, spec = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name_sym (Symbol)
  • type_info (Hash{Symbol=>Object}, Proc, FinchAPI::Converter, Class)
  • spec (Hash{Symbol=>Object}) (defaults to: {})

    .

    @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const

    @option spec [Proc] :enum

    @option spec [Proc] :union

    @option spec [Boolean] :“nil?”



956
957
958
# File 'lib/finch-api/base_model.rb', line 956

def optional(name_sym, type_info, spec = {})
  add_field(name_sym, required: false, type_info: type_info, spec: spec)
end

.required(name_sym, type_info, spec = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name_sym (Symbol)
  • type_info (Hash{Symbol=>Object}, Proc, FinchAPI::Converter, Class)
  • spec (Hash{Symbol=>Object}) (defaults to: {})

    .

    @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const

    @option spec [Proc] :enum

    @option spec [Proc] :union

    @option spec [Boolean] :“nil?”



937
938
939
# File 'lib/finch-api/base_model.rb', line 937

def required(name_sym, type_info, spec = {})
  add_field(name_sym, required: true, type_info: type_info, spec: spec)
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


994
# File 'lib/finch-api/base_model.rb', line 994

def ==(other) = self.class == other.class && @data == other.to_h

#[](key) ⇒ Object?

Returns the raw value associated with the given key, if found. Otherwise, nil is

returned.

It is valid to lookup keys that are not in the API spec, for example to access
undocumented features. This method does not parse response data into
higher-level types. Lookup by anything other than a Symbol is an ArgumentError.

Parameters:

  • key (Symbol)

Returns:

  • (Object, nil)


1115
1116
1117
1118
1119
1120
1121
# File 'lib/finch-api/base_model.rb', line 1115

def [](key)
  unless key.instance_of?(Symbol)
    raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}")
  end

  @data[key]
end

#deconstruct_keys(keys) ⇒ Hash{Symbol=>Object}

Parameters:

  • keys (Array<Symbol>, nil)

Returns:

  • (Hash{Symbol=>Object})


1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
# File 'lib/finch-api/base_model.rb', line 1140

def deconstruct_keys(keys)
  (keys || self.class.known_fields.keys)
    .filter_map do |k|
      unless self.class.known_fields.key?(k)
        next
      end

      [k, public_send(k)]
    end
    .to_h
end

#inspectString

Returns:

  • (String)


1165
1166
1167
1168
1169
1170
1171
1172
# File 'lib/finch-api/base_model.rb', line 1165

def inspect
  rows = self.class.known_fields.keys.map do
    "#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}"
  rescue FinchAPI::ConversionError
    "#{_1}=#{@data.fetch(_1)}"
  end
  "#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>"
end

#to_hHash{Symbol=>Object} Also known as: to_hash

Returns a Hash of the data underlying this object. O(1)

Keys are Symbols and values are the raw values from the response. The return
value indicates which values were ever set on the object. i.e. there will be a
key in this hash if they ever were, even if the set value was nil.

This method is not recursive. The returned value is shared by the object, so it
should not be mutated.

Returns:

  • (Hash{Symbol=>Object})


1133
# File 'lib/finch-api/base_model.rb', line 1133

def to_h = @data