Module: MDEXClient::ActiveRecord::Searchable::ClassMethods
- Defined in:
- lib/mdex_client/active_record/extensions.rb
Instance Method Summary collapse
- #mdex_additional_record_attributes ⇒ Object
- #mdex_additional_record_attributes=(attributes) ⇒ Object
- #mdex_client ⇒ Object
- #mdex_client=(client) ⇒ Object
- #mdex_field_mapping ⇒ Object
- #mdex_field_mapping=(mapping) ⇒ Object
- #mdex_find(params = {}) ⇒ Object
- #mdex_included_record_attributes ⇒ Object
- #mdex_navigation_query(params = {}) ⇒ Object
- #new_from_record(record) ⇒ Object
Instance Method Details
#mdex_additional_record_attributes ⇒ Object
19 20 21 |
# File 'lib/mdex_client/active_record/extensions.rb', line 19 def mdex_additional_record_attributes @@mdex_additional_record_attributes ||= Set.new end |
#mdex_additional_record_attributes=(attributes) ⇒ Object
15 16 17 |
# File 'lib/mdex_client/active_record/extensions.rb', line 15 def mdex_additional_record_attributes=(attributes) @@mdex_additional_record_attributes = Set.new(attributes) end |
#mdex_client ⇒ Object
27 28 29 |
# File 'lib/mdex_client/active_record/extensions.rb', line 27 def mdex_client @@mdex_client end |
#mdex_client=(client) ⇒ Object
23 24 25 |
# File 'lib/mdex_client/active_record/extensions.rb', line 23 def mdex_client=(client) @@mdex_client = client end |
#mdex_field_mapping ⇒ Object
11 12 13 |
# File 'lib/mdex_client/active_record/extensions.rb', line 11 def mdex_field_mapping @@mdex_field_mapping ||= { "id" => "id" } end |
#mdex_field_mapping=(mapping) ⇒ Object
7 8 9 |
# File 'lib/mdex_client/active_record/extensions.rb', line 7 def mdex_field_mapping=(mapping) @@mdex_field_mapping = mapping end |
#mdex_find(params = {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/mdex_client/active_record/extensions.rb', line 49 def mdex_find(params={}) query = (params) result = mdex_client.(query) shim_objects = result.records.collect { |record| new_from_record(record) } return query, result, shim_objects end |
#mdex_included_record_attributes ⇒ Object
31 32 33 |
# File 'lib/mdex_client/active_record/extensions.rb', line 31 def mdex_included_record_attributes mdex_additional_record_attributes | mdex_field_mapping.keys end |
#mdex_navigation_query(params = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/mdex_client/active_record/extensions.rb', line 41 def (params={}) query = MDEXClient::MData::NavigationQuery.new(params) query.included_record_attributes = mdex_included_record_attributes query.expose_all_refinements = true return query end |
#new_from_record(record) ⇒ Object
35 36 37 38 39 |
# File 'lib/mdex_client/active_record/extensions.rb', line 35 def new_from_record(record) obj = new obj.mdex_attributes = record.attributes obj end |