Class: Io::Flow::V0::Models::FieldValidationRule
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::FieldValidationRule
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
FieldValidationMax, FieldValidationMin, FieldValidationPattern, FieldValidationRequired, FieldValidationRequiredIfPresent, FieldValidationRuleUndefinedType
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ FieldValidationRule
constructor
A new instance of FieldValidationRule.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ FieldValidationRule
Returns a new instance of FieldValidationRule.
12100 12101 12102 12103 12104 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12100 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'FieldValidationRule') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
12098 12099 12100 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12098 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12114 def FieldValidationRule.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip if discriminator.empty? raise "Union type[field_validation_rule] requires a field named 'discriminator'" end case discriminator when Types::FIELD_VALIDATION_REQUIRED; FieldValidationRequired.new(hash) when Types::FIELD_VALIDATION_REQUIRED_IF_PRESENT; FieldValidationRequiredIfPresent.new(hash) when Types::FIELD_VALIDATION_MIN; FieldValidationMin.new(hash) when Types::FIELD_VALIDATION_MAX; FieldValidationMax.new(hash) when Types::FIELD_VALIDATION_PATTERN; FieldValidationPattern.new(hash) else FieldValidationRuleUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
12106 12107 12108 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12106 def subtype_to_hash raise 'Cannot serialize an instance of field_validation_rule directly - must use one of the specific types: field_validation_required, field_validation_required_if_present, field_validation_min, field_validation_max, field_validation_pattern' end |
#to_hash ⇒ Object
12110 12111 12112 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12110 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |