Class: LinkedRails::Form::FieldFactory
- Inherits:
-
Object
- Object
- LinkedRails::Form::FieldFactory
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/linked_rails/form/field_factory.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DATABASE_ERRORS =
[ 'PG::ConnectionBad'.safe_constantize, ActiveRecord::StatementInvalid, ActiveRecord::ConnectionNotEstablished ].compact.freeze
- MAX_STR_LEN =
255- VALIDATOR_SELECTORS =
[ [:min_length, ActiveModel::Validations::LengthValidator, :minimum], [:min_inclusive, ActiveModel::Validations::NumericalityValidator, :greater_than_or_equal_to], [:max_length, ActiveModel::Validations::LengthValidator, :maximum], [:max_inclusive, ActiveModel::Validations::NumericalityValidator, :less_than_or_equal_to], [:pattern, ActiveModel::Validations::FormatValidator, :with], [:presence, ActiveModel::Validations::PresenceValidator, nil], [:sh_in, ActiveModel::Validations::InclusionValidator, :in] ].freeze
Instance Attribute Summary collapse
-
#field_options ⇒ Object
Returns the value of attribute field_options.
-
#form ⇒ Object
Returns the value of attribute form.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
Instance Attribute Details
#field_options ⇒ Object
Returns the value of attribute field_options.
23 24 25 |
# File 'app/models/linked_rails/form/field_factory.rb', line 23 def @field_options end |
#form ⇒ Object
Returns the value of attribute form.
23 24 25 |
# File 'app/models/linked_rails/form/field_factory.rb', line 23 def form @form end |
#key ⇒ Object
Returns the value of attribute key.
23 24 25 |
# File 'app/models/linked_rails/form/field_factory.rb', line 23 def key @key end |
Instance Method Details
#condition_or_field ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/linked_rails/form/field_factory.rb', line 34 def condition_or_field return @condition_or_field if instance_variable_defined?(:@condition_or_field) alternatives = node_shapes_for( key, property: [:if] || [], sh_not: [:unless] || [] ) @condition_or_field = if alternatives.count == 1 Condition.new(shape: alternatives.first, pass: field) elsif alternatives.count.positive? Condition.new(shape: SHACL::NodeShape.new(or: alternatives), pass: field) else field end end |