Class: Botz::Binder::Multiple
- Inherits:
-
Object
- Object
- Botz::Binder::Multiple
- Defined in:
- lib/botz/binder.rb
Overview
binding multiple
Class Method Summary collapse
Instance Method Summary collapse
- #field(name) ⇒ Object
-
#initialize(binder) ⇒ Multiple
constructor
A new instance of Multiple.
Constructor Details
#initialize(binder) ⇒ Multiple
Returns a new instance of Multiple.
21 22 23 |
# File 'lib/botz/binder.rb', line 21 def initialize(binder) @binder = binder end |
Class Method Details
.bind(connector:, binder:, query:, block:) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/botz/binder.rb', line 14 def self.bind(connector:, binder:, query:, block:) multiple_binding_class = self connector.field(binder, query) do |elements| multiple_binding_class.new(binder.class).instance_exec(elements, &block) end end |
Instance Method Details
#field(name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/botz/binder.rb', line 25 def field(name) @binder.field_names << name @binder.field_names.uniq! @binder.result_class.define(name) result = yield @binder.define_method(name) { result } end |