Class: BigIndex::IndexField
- Inherits:
-
Object
- Object
- BigIndex::IndexField
- Includes:
- Assertions
- Defined in:
- lib/big_index/index_field.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#field_type ⇒ Object
readonly
Returns the value of attribute field_type.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(params, block = nil) ⇒ IndexField
constructor
A new instance of IndexField.
- #method_missing(name) ⇒ Object
Methods included from Assertions
Constructor Details
#initialize(params, block = nil) ⇒ IndexField
Returns a new instance of IndexField.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/big_index/index_field.rb', line 10 def initialize(params, block = nil) raise "IndexField requires at least a field name" unless params.size > 0 @params = params.dup @block = block @field_name = params.shift assert_kind_of 'field_name', @field_name, Symbol, String unless params.empty? || ![Symbol, String].include?(params.first.class) @field_type = params.shift end @options = params.shift || {} assert_kind_of 'options', @options, Hash # Setting the default values @options[:finder_name] ||= field_name @field_type ||= :text end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
35 36 37 |
# File 'lib/big_index/index_field.rb', line 35 def method_missing(name) @options[name.to_sym] || super end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
8 9 10 |
# File 'lib/big_index/index_field.rb', line 8 def block @block end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
8 9 10 |
# File 'lib/big_index/index_field.rb', line 8 def field @field end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
8 9 10 |
# File 'lib/big_index/index_field.rb', line 8 def field_name @field_name end |
#field_type ⇒ Object (readonly)
Returns the value of attribute field_type.
8 9 10 |
# File 'lib/big_index/index_field.rb', line 8 def field_type @field_type end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/big_index/index_field.rb', line 8 def @options end |
Instance Method Details
#[](name) ⇒ Object
31 32 33 |
# File 'lib/big_index/index_field.rb', line 31 def [](name) @options[name] end |