Class: Cortex::FieldType

Inherits:
ApplicationRecord show all
Extended by:
ActiveSupport::DescendantsTracker
Defined in:
app/models/cortex/field_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'app/models/cortex/field_type.rb', line 6

def data
  @data
end

#fieldObject

Returns the value of attribute field.



5
6
7
# File 'app/models/cortex/field_type.rb', line 5

def field
  @field
end

#field_nameObject

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

#metadataObject

Returns the value of attribute metadata.



6
7
8
# File 'app/models/cortex/field_type.rb', line 6

def 
  @metadata
end

#validationsObject

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_namesObject



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

Returns:

  • (Boolean)


28
29
30
# File 'app/models/cortex/field_type.rb', line 28

def acceptable_validations?
  valid_types? && valid_options?
end

#elasticsearch_mappingObject



16
17
18
# File 'app/models/cortex/field_type.rb', line 16

def elasticsearch_mapping
  raise 'Not implemented'
end

#valid_options?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'app/models/cortex/field_type.rb', line 38

def valid_options?
  validations.all? do |type, options|
    self.send(VALIDATION_TYPES[type])
  end
end

#valid_types?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'app/models/cortex/field_type.rb', line 32

def valid_types?
  validations.all? do |type, options|
    VALIDATION_TYPES.include?(type.to_sym)
  end
end