Module: Casino::Collection
- Defined in:
- lib/casino/collection.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#answer(method_name) ⇒ Object
readonly
Returns the value of attribute answer.
-
#intersection ⇒ Object
readonly
Returns the value of attribute intersection.
Class Method Summary collapse
Instance Method Summary collapse
- #dimensions ⇒ Object
- #document ⇒ Object
- #focus ⇒ Object
- #insert(*documents) ⇒ Object
- #key ⇒ Object
- #projection ⇒ Object
- #query(label, *criteria) ⇒ Object
- #questions ⇒ Object
- #results ⇒ Object
- #store ⇒ Object
- #update ⇒ Object
Instance Attribute Details
#answer(method_name) ⇒ Object (readonly)
Returns the value of attribute answer.
3 4 5 |
# File 'lib/casino/collection.rb', line 3 def answer @answer end |
#intersection ⇒ Object (readonly)
Returns the value of attribute intersection.
3 4 5 |
# File 'lib/casino/collection.rb', line 3 def intersection @intersection end |
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/casino/collection.rb', line 5 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#dimensions ⇒ Object
34 35 36 |
# File 'lib/casino/collection.rb', line 34 def dimensions registry[:dimension] end |
#document ⇒ Object
50 51 52 |
# File 'lib/casino/collection.rb', line 50 def document @document ||= Casino::Document.new(key, questions.map(&:name)).compose end |
#focus ⇒ Object
42 43 44 |
# File 'lib/casino/collection.rb', line 42 def focus registry[:focus] end |
#insert(*documents) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/casino/collection.rb', line 84 def insert(*documents) matching_intersections = match_intersections documents matching_results = determine_results matching_intersections merge matching_results stored_results.where(id: matching_results.map(&:id)) end |
#key ⇒ Object
54 55 56 |
# File 'lib/casino/collection.rb', line 54 def key Digest::SHA1.hexdigest(key_base) end |
#projection ⇒ Object
58 59 60 |
# File 'lib/casino/collection.rb', line 58 def projection Casino::Projection.new(focus_model).where(intersection.selector) end |
#query(label, *criteria) ⇒ Object
66 67 68 |
# File 'lib/casino/collection.rb', line 66 def query(label, *criteria) Query.new(label, [], *criteria) end |
#questions ⇒ Object
38 39 40 |
# File 'lib/casino/collection.rb', line 38 def questions registry[:question] end |
#results ⇒ Object
70 71 72 73 |
# File 'lib/casino/collection.rb', line 70 def results persist_results if pending_results.any? stored_results end |
#store ⇒ Object
46 47 48 |
# File 'lib/casino/collection.rb', line 46 def store @store ||= Store.new document end |
#update ⇒ Object
75 76 77 78 |
# File 'lib/casino/collection.rb', line 75 def update merge all_results stored_results end |