Class: Cortex::FieldType
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Cortex::FieldType
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- app/models/cortex/field_type.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#field ⇒ Object
Returns the value of attribute field.
-
#field_name ⇒ Object
Returns the value of attribute field_name.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#validations ⇒ Object
Returns the value of attribute validations.
Class Method Summary collapse
Instance Method Summary collapse
- #acceptable_validations? ⇒ Boolean
- #elasticsearch_mapping ⇒ Object
- #valid_options? ⇒ Boolean
- #valid_types? ⇒ Boolean
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'app/models/cortex/field_type.rb', line 6 def data @data end |
#field ⇒ Object
Returns the value of attribute field.
5 6 7 |
# File 'app/models/cortex/field_type.rb', line 5 def field @field end |
#field_name ⇒ Object
Returns the value of attribute field_name.
5 6 7 |
# File 'app/models/cortex/field_type.rb', line 5 def field_name @field_name end |
#metadata ⇒ Object
Returns the value of attribute metadata.
6 7 8 |
# File 'app/models/cortex/field_type.rb', line 6 def @metadata end |
#validations ⇒ Object
Returns the value of attribute validations.
6 7 8 |
# File 'app/models/cortex/field_type.rb', line 6 def validations @validations end |
Class Method Details
.direct_descendant_names ⇒ Object
8 9 10 |
# File 'app/models/cortex/field_type.rb', line 8 def self.direct_descendant_names direct_descendants.map { |descendant| descendant.name.underscore } end |
.get_subtype_constant(descendant_name) ⇒ Object
12 13 14 |
# File 'app/models/cortex/field_type.rb', line 12 def self.get_subtype_constant(descendant_name) descendant_name.camelize.constantize end |
Instance Method Details
#acceptable_validations? ⇒ Boolean
28 29 30 |
# File 'app/models/cortex/field_type.rb', line 28 def acceptable_validations? valid_types? && end |
#elasticsearch_mapping ⇒ Object
16 17 18 |
# File 'app/models/cortex/field_type.rb', line 16 def elasticsearch_mapping raise 'Not implemented' end |
#valid_options? ⇒ Boolean
38 39 40 41 42 |
# File 'app/models/cortex/field_type.rb', line 38 def validations.all? do |type, | self.send(VALIDATION_TYPES[type]) end end |
#valid_types? ⇒ Boolean
32 33 34 35 36 |
# File 'app/models/cortex/field_type.rb', line 32 def valid_types? validations.all? do |type, | VALIDATION_TYPES.include?(type.to_sym) end end |