Class: AgnosticBackend::Indexable::FieldType
- Inherits:
-
Object
- Object
- AgnosticBackend::Indexable::FieldType
- Defined in:
- lib/agnostic_backend/indexable/field_type.rb
Constant Summary collapse
- INTEGER =
:integer
- DOUBLE =
:double
- STRING =
literal string (i.e. should be matched exactly)
:string
- STRING_ARRAY =
:string_array
- TEXT =
:text
- TEXT_ARRAY =
:text_array
- DATE =
datetime
:date
- DATE_ARRAY =
datetime
:date_array
- BOOLEAN =
:boolean
- STRUCT =
a nested structure containing other values
:struct
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #get_option(option_name) ⇒ Object
- #has_option(option_name) ⇒ Object
-
#initialize(type, **options) ⇒ FieldType
constructor
A new instance of FieldType.
- #matches?(type) ⇒ Boolean
- #nested? ⇒ Boolean
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 23 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 23 def type @type end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 15 def self.all constants.map { |constant| const_get(constant) } end |
.exists?(type) ⇒ Boolean
19 20 21 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 19 def self.exists?(type) all.include? type end |
Instance Method Details
#get_option(option_name) ⇒ Object
39 40 41 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 39 def get_option(option_name) @options[option_name.to_sym] end |
#has_option(option_name) ⇒ Object
43 44 45 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 43 def has_option(option_name) @options.has_key? option_name.to_sym end |
#matches?(type) ⇒ Boolean
35 36 37 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 35 def matches?(type) self.type == type end |
#nested? ⇒ Boolean
31 32 33 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 31 def nested? type == STRUCT end |