Class: Microjoin::JoinRespondant
- Inherits:
-
Object
- Object
- Microjoin::JoinRespondant
- Defined in:
- lib/microjoin/join_respondant.rb
Instance Attribute Summary collapse
-
#l ⇒ Object
readonly
Returns the value of attribute l.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Instance Method Summary collapse
-
#initialize(l, r) ⇒ JoinRespondant
constructor
A new instance of JoinRespondant.
- #on(left: nil, right: nil) ⇒ Object
Constructor Details
#initialize(l, r) ⇒ JoinRespondant
Returns a new instance of JoinRespondant.
5 6 7 |
# File 'lib/microjoin/join_respondant.rb', line 5 def initialize(l,r) @l, @r = l, r end |
Instance Attribute Details
#l ⇒ Object (readonly)
Returns the value of attribute l.
3 4 5 |
# File 'lib/microjoin/join_respondant.rb', line 3 def l @l end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
3 4 5 |
# File 'lib/microjoin/join_respondant.rb', line 3 def mode @mode end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
3 4 5 |
# File 'lib/microjoin/join_respondant.rb', line 3 def r @r end |
Instance Method Details
#on(left: nil, right: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/microjoin/join_respondant.rb', line 9 def on(left: nil, right: nil) if block_given? raise ArgumentError, 'Cannot specify both general and specialized join keys' unless [left, right].compact == [] left = right = Proc.new end gl = l.group_by(&left) gr = r.group_by(&right) send("join_#{mode}", gl, gr) end |