Class: Ripple::Index
- Includes:
- Translation
- Defined in:
- lib/ripple/indexes.rb
Overview
Represents a Secondary Index on a Document
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#index_key ⇒ Object
The key under which a value will be indexed.
-
#index_type ⇒ "bin", ...
The type of index used for this property.
-
#initialize(key, property_type, index_type = true) { ... } ⇒ Index
constructor
Creates an index for a Document.
-
#to_index_value(value) ⇒ String, ...
Converts an attribute to a value appropriate for storing in a secondary index.
Methods included from Translation
Constructor Details
#initialize(key, property_type, index_type = true) { ... } ⇒ Index
Creates an index for a Document
108 109 110 |
# File 'lib/ripple/indexes.rb', line 108 def initialize(key, property_type, index_type=true, &block) @key, @type, @index, @block = key, property_type, index_type, block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
100 101 102 |
# File 'lib/ripple/indexes.rb', line 100 def block @block end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
100 101 102 |
# File 'lib/ripple/indexes.rb', line 100 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
100 101 102 |
# File 'lib/ripple/indexes.rb', line 100 def type @type end |
Instance Method Details
#index_key ⇒ Object
The key under which a value will be indexed
114 115 116 |
# File 'lib/ripple/indexes.rb', line 114 def index_key "#{key}_#{index_type}" end |
#index_type ⇒ "bin", ...
Returns the type of index used for this property.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ripple/indexes.rb', line 129 def index_type @index_type ||= case @index when /^bin|int$/ @index when Class determine_index_type(@index) else determine_index_type(@type) end end |
#to_index_value(value) ⇒ String, ...
Converts an attribute to a value appropriate for storing in a secondary index.
123 124 125 |
# File 'lib/ripple/indexes.rb', line 123 def to_index_value(value) value.to_ripple_index(index_type) end |