Class: Dynamoid::TransactionRead::Find
- Inherits:
-
Object
- Object
- Dynamoid::TransactionRead::Find
- Defined in:
- lib/dynamoid/transaction_read/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.
8 9 10 11 12 |
# File 'lib/dynamoid/transaction_read/find.rb', line 8 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.
6 7 8 |
# File 'lib/dynamoid/transaction_read/find.rb', line 6 def model_class @model_class end |
Instance Method Details
#action_request ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/dynamoid/transaction_read/find.rb', line 22 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
18 19 20 |
# File 'lib/dynamoid/transaction_read/find.rb', line 18 def observable_by_user_result nil end |
#on_registration ⇒ Object
14 15 16 |
# File 'lib/dynamoid/transaction_read/find.rb', line 14 def on_registration validate_primary_key! end |
#process_responses(responses) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dynamoid/transaction_read/find.rb', line 30 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 |