Class: ActiveRecord::ConnectionAdapters::Elasticsearch::Column
- Inherits:
-
ConnectionAdapters::Column
- Object
- ConnectionAdapters::Column
- ActiveRecord::ConnectionAdapters::Elasticsearch::Column
- Defined in:
- lib/active_record/connection_adapters/elasticsearch/column.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#virtual ⇒ Object
readonly
Returns the value of attribute virtual.
Instance Method Summary collapse
-
#comment ⇒ Object
returns comment from meta.
-
#enabled? ⇒ Boolean
returns true if this column is enabled (= searchable by queries).
-
#field_names ⇒ Array
returns a array of field names.
-
#fields? ⇒ Boolean
returns true if this column has nested fields To receive the nested names just call +#fields+ on this object.
-
#initialize(name, default, sql_type_metadata = nil, virtual: false, fields: nil, properties: nil, meta: nil, enabled: nil, **kwargs) ⇒ Column
constructor
A new instance of Column.
-
#meta? ⇒ Boolean
returns true if this column has meta information To receive the nested meta-data just call +#meta+ on this object.
-
#properties? ⇒ Boolean
returns true if this column has nested properties To receive the nested names just call +#properties+ on this object.
-
#property_names ⇒ Array
returns a array of property names.
-
#virtual? ⇒ Boolean
returns true if this column is virtual.
Constructor Details
#initialize(name, default, sql_type_metadata = nil, virtual: false, fields: nil, properties: nil, meta: nil, enabled: nil, **kwargs) ⇒ Column
Returns a new instance of Column.
10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 10 def initialize(name, default, = nil, virtual: false, fields: nil, properties: nil, meta: nil, enabled: nil, **kwargs) @virtual = virtual @fields = fields.presence || [] @properties = properties.presence || [] @meta = .presence || {} @enabled = enabled.nil? ? true : enabled super(name, default, , true, nil, **kwargs) end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
8 9 10 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 8 def enabled @enabled end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 8 def fields @fields end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
8 9 10 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 8 def @meta end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
8 9 10 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 8 def properties @properties end |
#virtual ⇒ Object (readonly)
Returns the value of attribute virtual.
8 9 10 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 8 def virtual @virtual end |
Instance Method Details
#comment ⇒ Object
returns comment from meta
21 22 23 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 21 def comment && ['comment'] end |
#enabled? ⇒ Boolean
returns true if this column is enabled (= searchable by queries)
27 28 29 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 27 def enabled? !!enabled end |
#field_names ⇒ Array
returns a array of field names
61 62 63 64 65 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 61 def field_names return [] unless fields? fields.map { |field| field['name'] } end |
#fields? ⇒ Boolean
returns true if this column has nested fields To receive the nested names just call +#fields+ on this object.
48 49 50 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 48 def fields? fields.present? end |
#meta? ⇒ Boolean
returns true if this column has meta information To receive the nested meta-data just call +#meta+ on this object.
41 42 43 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 41 def .present? end |
#properties? ⇒ Boolean
returns true if this column has nested properties To receive the nested names just call +#properties+ on this object.
55 56 57 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 55 def properties? properties.present? end |
#property_names ⇒ Array
returns a array of property names
69 70 71 72 73 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 69 def property_names return [] unless properties? properties.map { |property| property['name'] } end |
#virtual? ⇒ Boolean
returns true if this column is virtual. Virtual columns cannot be saved.
34 35 36 |
# File 'lib/active_record/connection_adapters/elasticsearch/column.rb', line 34 def virtual? !!virtual end |