Class: MongoidEmbedFinder::Runner
- Inherits:
-
Object
- Object
- MongoidEmbedFinder::Runner
- Defined in:
- lib/mongoid_embed_finder/runner.rb
Instance Method Summary collapse
- #first(parent: {}, **attrs) ⇒ Object
-
#initialize(child_class, parent_relation_name) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(child_class, parent_relation_name) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 |
# File 'lib/mongoid_embed_finder/runner.rb', line 8 def initialize(child_class, parent_relation_name) @relation_discovery = RelationDiscovery.new( child_class, parent_relation_name) end |
Instance Method Details
#first(parent: {}, **attrs) ⇒ Object
13 14 15 16 17 |
# File 'lib/mongoid_embed_finder/runner.rb', line 13 def first(parent: {}, **attrs) nested_attrs = find_first(attrs, parent: parent) return nil unless nested_attrs build_child_with_parent(nested_attrs) end |