Module: FinchAPI::Internal::Type::Enum Private
- Includes:
- Converter
- Included in:
- Models::AccountUpdateEvent::Data::AuthenticationMethod::Type, Models::AccountUpdateEvent::EventType, Models::CompanyEvent::EventType, Models::Connect::SessionNewParams::Integration::AuthMethod, Models::Connect::SessionNewParams::Product, Models::Connect::SessionNewParams::Sandbox, Models::Connect::SessionReauthenticateParams::Product, Models::ConnectionStatusType, Models::CreateAccessTokenResponse::ClientType, Models::CreateAccessTokenResponse::ConnectionType, Models::DirectoryEvent::EventType, Models::EmploymentEvent::EventType, Models::HRIS::BenefitContribution::Type, Models::HRIS::BenefitCreateParams::CompanyContribution::Type, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::CompanyContribution, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::EmployeeDeduction, Models::HRIS::BenefitFeaturesAndOperations::SupportedFeatures::HsaContributionLimit, Models::HRIS::BenefitFrequency, Models::HRIS::BenefitListSupportedBenefitsResponse::CompanyContribution, Models::HRIS::BenefitListSupportedBenefitsResponse::EmployeeDeduction, Models::HRIS::BenefitListSupportedBenefitsResponse::HsaContributionLimit, Models::HRIS::BenefitType, Models::HRIS::Benefits::IndividualBenefit::Body::HsaContributionLimit, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::AnnualContributionLimit, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::CompanyContribution::Type, Models::HRIS::Benefits::IndividualEnrollManyParams::Individual::Configuration::EmployeeDeduction::Type, Models::HRIS::Company::PayStatementItem::RuleCreateParams::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleCreateParams::EntityType, Models::HRIS::Company::PayStatementItem::RuleCreateResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleCreateResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleDeleteResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleDeleteResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleListResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleListResponse::EntityType, Models::HRIS::Company::PayStatementItem::RuleUpdateResponse::Condition::Operator, Models::HRIS::Company::PayStatementItem::RuleUpdateResponse::EntityType, Models::HRIS::Company::PayStatementItemListParams::Category, Models::HRIS::Company::PayStatementItemListResponse::Category, Models::HRIS::CompanyBenefit::CompanyContribution::Type, Models::HRIS::DocumentListParams::Type, Models::HRIS::DocumentResponse::Type, Models::HRIS::EmploymentData::UnionMember0::Employment::Subtype, Models::HRIS::EmploymentData::UnionMember0::Employment::Type, Models::HRIS::EmploymentData::UnionMember0::EmploymentStatus, Models::HRIS::HRISCompany::Account::AccountType, Models::HRIS::HRISCompany::Entity::Subtype, Models::HRIS::HRISCompany::Entity::Type, Models::HRIS::Individual::UnionMember0::Email::Type, Models::HRIS::Individual::UnionMember0::Ethnicity, Models::HRIS::Individual::UnionMember0::Gender, Models::HRIS::Individual::UnionMember0::PhoneNumber::Type, Models::HRIS::PayStatement::Earning::Type, Models::HRIS::PayStatement::PaymentMethod, Models::HRIS::PayStatement::Tax::Type, Models::HRIS::PayStatement::Type, Models::HRIS::Payment::PayFrequency, Models::HRIS::SupportedBenefit::CompanyContribution, Models::HRIS::SupportedBenefit::EmployeeDeduction, Models::HRIS::SupportedBenefit::HsaContributionLimit, Models::HRIS::W42005::Data::Exemption, Models::HRIS::W42005::Data::FilingStatus, Models::HRIS::W42005::Type, Models::HRIS::W42020::Data::FilingStatus, Models::HRIS::W42020::Type, Models::Income::Unit, Models::IndividualEvent::EventType, Models::Introspection::AuthenticationMethod::Type, Models::Introspection::ClientType, Models::Introspection::ConnectionType, Models::JobCompletionEvent::EventType, Models::Jobs::AutomatedAsyncJob::Status, Models::Jobs::AutomatedAsyncJob::Type, Models::Jobs::AutomatedCreateParams::Type, Models::Jobs::ManualAsyncJob::Status, Models::OperationSupport, Models::PayStatementEvent::EventType, Models::PaymentEvent::EventType, Models::Payroll::PayGroupListResponse::PayFrequency, Models::Payroll::PayGroupRetrieveResponse::PayFrequency, Models::Provider::AuthenticationMethod::Type, Models::Sandbox::CompanyUpdateParams::Account::AccountType, Models::Sandbox::CompanyUpdateParams::Entity::Subtype, Models::Sandbox::CompanyUpdateParams::Entity::Type, Models::Sandbox::CompanyUpdateResponse::Account::AccountType, Models::Sandbox::CompanyUpdateResponse::Entity::Subtype, Models::Sandbox::CompanyUpdateResponse::Entity::Type, Models::Sandbox::ConnectionCreateParams::AuthenticationType, Models::Sandbox::ConnectionCreateResponse::AuthenticationType, Models::Sandbox::Connections::AccountCreateParams::AuthenticationType, Models::Sandbox::Connections::AccountCreateResponse::AuthenticationType, Models::Sandbox::Connections::AccountUpdateResponse::AuthenticationType, Models::Sandbox::DirectoryCreateParams::Body::Email::Type, Models::Sandbox::DirectoryCreateParams::Body::Employment::Subtype, Models::Sandbox::DirectoryCreateParams::Body::Employment::Type, Models::Sandbox::DirectoryCreateParams::Body::EmploymentStatus, Models::Sandbox::DirectoryCreateParams::Body::Ethnicity, Models::Sandbox::DirectoryCreateParams::Body::Gender, Models::Sandbox::DirectoryCreateParams::Body::PhoneNumber::Type, Models::Sandbox::EmploymentUpdateParams::Employment::Subtype, Models::Sandbox::EmploymentUpdateParams::Employment::Type, Models::Sandbox::EmploymentUpdateParams::EmploymentStatus, Models::Sandbox::EmploymentUpdateResponse::Employment::Subtype, Models::Sandbox::EmploymentUpdateResponse::Employment::Type, Models::Sandbox::EmploymentUpdateResponse::EmploymentStatus, Models::Sandbox::IndividualUpdateParams::Email::Type, Models::Sandbox::IndividualUpdateParams::Ethnicity, Models::Sandbox::IndividualUpdateParams::Gender, Models::Sandbox::IndividualUpdateParams::PhoneNumber::Type, Models::Sandbox::IndividualUpdateResponse::Email::Type, Models::Sandbox::IndividualUpdateResponse::Ethnicity, Models::Sandbox::IndividualUpdateResponse::Gender, Models::Sandbox::IndividualUpdateResponse::PhoneNumber::Type, Models::Sandbox::JobCreateParams::Type, Models::Sandbox::Jobs::SandboxJobConfiguration::CompletionStatus, Models::Sandbox::Jobs::SandboxJobConfiguration::Type, Models::Sandbox::PaymentCreateParams::PayStatement::Earning::Type, Models::Sandbox::PaymentCreateParams::PayStatement::PaymentMethod, Models::Sandbox::PaymentCreateParams::PayStatement::Tax::Type, Models::Sandbox::PaymentCreateParams::PayStatement::Type
- Defined in:
- lib/finch_api/internal/type/enum.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
A value from among a specified list of options. OpenAPI enum values map to Ruby values in the SDK as follows:
-
boolean => true | false
-
integer => Integer
-
float => Float
-
string => Symbol
We can therefore convert string values to Symbols, but can’t convert other values safely.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #===(other) ⇒ Boolean
-
#coerce(value, state:) ⇒ Symbol, Object
private
Unlike with primitives, ‘Enum` additionally validates that the value is a member of the enum.
- #dump(value, state: ) ⇒ Symbol, Object private
- #hash ⇒ Integer
- #inspect(depth: 0) ⇒ String private
-
#values ⇒ Array<NilClass, Boolean, Integer, Float, Symbol>
private
All of the valid Symbol values for this enum.
Methods included from Converter
coerce, dump, inspect, type_info
Instance Method Details
#==(other) ⇒ Boolean
63 64 65 66 67 |
# File 'lib/finch_api/internal/type/enum.rb', line 63 def ==(other) # rubocop:disable Style/CaseEquality FinchAPI::Internal::Type::Enum === other && other.values.to_set == values.to_set # rubocop:enable Style/CaseEquality end |
#===(other) ⇒ Boolean
56 |
# File 'lib/finch_api/internal/type/enum.rb', line 56 def ===(other) = values.include?(other) |
#coerce(value, state:) ⇒ 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.
Unlike with primitives, ‘Enum` additionally validates that the value is a member of the enum.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/finch_api/internal/type/enum.rb', line 90 def coerce(value, state:) exactness = state.fetch(:exactness) val = value.is_a?(String) ? value.to_sym : value if values.include?(val) exactness[:yes] += 1 val else exactness[values.first&.class == val.class ? :maybe : :no] += 1 value end end |
#dump(value, state: ) ⇒ 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.
|
|
# File 'lib/finch_api/internal/type/enum.rb', line 103
|
#hash ⇒ Integer
72 |
# File 'lib/finch_api/internal/type/enum.rb', line 72 def hash = values.to_set.hash |
#inspect(depth: 0) ⇒ String
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.
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/finch_api/internal/type/enum.rb', line 119 def inspect(depth: 0) if depth.positive? return is_a?(Module) ? super() : self.class.name end members = values.map { FinchAPI::Internal::Type::Converter.inspect(_1, depth: depth.succ) } prefix = is_a?(Module) ? name : self.class.name "#{prefix}[#{members.join(' | ')}]" end |
#values ⇒ Array<NilClass, Boolean, Integer, Float, Symbol>
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.
All of the valid Symbol values for this enum.
49 |
# File 'lib/finch_api/internal/type/enum.rb', line 49 def values = constants.map { const_get(_1) } |