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- 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.
22 23 24 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 22 def @options end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 22 def type @type end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 14 def self.all constants.map { |constant| const_get(constant) } end |
.exists?(type) ⇒ Boolean
18 19 20 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 18 def self.exists?(type) all.include? type end |
Instance Method Details
#get_option(option_name) ⇒ Object
38 39 40 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 38 def get_option(option_name) @options[option_name.to_sym] end |
#has_option(option_name) ⇒ Object
42 43 44 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 42 def has_option(option_name) @options.has_key? option_name.to_sym end |
#matches?(type) ⇒ Boolean
34 35 36 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 34 def matches?(type) self.type == type end |
#nested? ⇒ Boolean
30 31 32 |
# File 'lib/agnostic_backend/indexable/field_type.rb', line 30 def nested? type == STRUCT end |