Class: Dynamoid::Transactions::Retrieval::Find
- Inherits:
-
Object
- Object
- Dynamoid::Transactions::Retrieval::Find
- Defined in:
- lib/dynamoid/transactions/retrieval/find.rb
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
Instance Method Summary collapse
- #action_request ⇒ Object
-
#initialize(model_class, *ids, **options) ⇒ Find
constructor
A new instance of Find.
- #observable_by_user_result ⇒ Object
- #on_registration ⇒ Object
- #process_responses(responses) ⇒ Object
Constructor Details
#initialize(model_class, *ids, **options) ⇒ Find
Returns a new instance of Find.
10 11 12 13 14 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 10 def initialize(model_class, *ids, **) @model_class = model_class @ids = ids @options = end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
8 9 10 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 8 def model_class @model_class end |
Instance Method Details
#action_request ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 24 def action_request if single_key_given? action_request_for_single_key else action_request_for_multiple_keys end end |
#observable_by_user_result ⇒ Object
20 21 22 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 20 def observable_by_user_result nil end |
#on_registration ⇒ Object
16 17 18 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 16 def on_registration validate_primary_key! end |
#process_responses(responses) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dynamoid/transactions/retrieval/find.rb', line 32 def process_responses(responses) models = responses.map do |response| if response.item @model_class.from_database(response.item) elsif @options[:raise_error] == false nil else = (responses) raise Dynamoid::Errors::RecordNotFound, end end unless single_key_given? models.compact! end models.each { |m| m&.run_callbacks :find } models end |