Class: ThinkingSphinx::ActiveRecord::Property
- Inherits:
-
Object
- Object
- ThinkingSphinx::ActiveRecord::Property
- Includes:
- Core::Property
- Defined in:
- lib/thinking_sphinx/active_record/property.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(model, columns, options = {}) ⇒ Property
constructor
A new instance of Property.
- #name ⇒ Object
- #rebase(associations, options) ⇒ Object
- #source_type ⇒ Object
Methods included from Core::Property
Constructor Details
#initialize(model, columns, options = {}) ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 13 14 15 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 8 def initialize(model, columns, = {}) @model, @options = model, @columns = Array(columns).collect { |column| column.respond_to?(:__name) ? column : ThinkingSphinx::ActiveRecord::Column.new(column) } end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 6 def columns @columns end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 6 def model @model end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 6 def @options end |
Instance Method Details
#name ⇒ Object
23 24 25 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 23 def name ([:as] || columns.first.__name).to_s end |
#rebase(associations, options) ⇒ Object
17 18 19 20 21 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 17 def rebase(associations, ) @columns = columns.inject([]) do |array, column| array + column.__replace(associations, [:to]) end end |
#source_type ⇒ Object
27 28 29 |
# File 'lib/thinking_sphinx/active_record/property.rb', line 27 def source_type [:source] end |