Class: BB::Builder
- Inherits:
-
Object
- Object
- BB::Builder
- Defined in:
- lib/b_b/builder.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#group_each ⇒ Object
readonly
Returns the value of attribute group_each.
-
#having ⇒ Object
readonly
Returns the value of attribute having.
-
#joins ⇒ Object
readonly
Returns the value of attribute joins.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#omit_record_if ⇒ Object
readonly
Returns the value of attribute omit_record_if.
-
#options ⇒ Object
Returns the value of attribute options.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#select ⇒ Object
readonly
Returns the value of attribute select.
-
#where ⇒ Object
readonly
Returns the value of attribute where.
Instance Method Summary collapse
- #add_offset_to_limit(offset) ⇒ Object
- #add_option_to_just_before_join(rel) ⇒ Object
- #append_joins(name) ⇒ Object
- #assign(name) ⇒ Object
- #build ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
8 9 10 11 |
# File 'lib/b_b/builder.rb', line 8 def initialize @joins = [] @options = {} end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def from @from end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def group @group end |
#group_each ⇒ Object (readonly)
Returns the value of attribute group_each.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def group_each @group_each end |
#having ⇒ Object (readonly)
Returns the value of attribute having.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def having @having end |
#joins ⇒ Object (readonly)
Returns the value of attribute joins.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def joins @joins end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def limit @limit end |
#omit_record_if ⇒ Object (readonly)
Returns the value of attribute omit_record_if.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def omit_record_if @omit_record_if end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/b_b/builder.rb', line 6 def @options end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def order @order end |
#select ⇒ Object (readonly)
Returns the value of attribute select.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def select @select end |
#where ⇒ Object (readonly)
Returns the value of attribute where.
3 4 5 |
# File 'lib/b_b/builder.rb', line 3 def where @where end |
Instance Method Details
#add_offset_to_limit(offset) ⇒ Object
36 37 38 39 40 |
# File 'lib/b_b/builder.rb', line 36 def add_offset_to_limit(offset) return if limit.nil? limit.[:offset] = offset end |
#add_option_to_just_before_join(rel) ⇒ Object
30 31 32 33 34 |
# File 'lib/b_b/builder.rb', line 30 def add_option_to_just_before_join(rel) return if joins.empty? joins.last.[:rel] = rel end |
#append_joins(name) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/b_b/builder.rb', line 23 def append_joins(name) register_factory(name).tap do |factory| (factory) joins << factory end end |
#assign(name) ⇒ Object
17 18 19 20 21 |
# File 'lib/b_b/builder.rb', line 17 def assign(name) get_factory_ivar(name).tap do |factory| (factory) end end |
#build ⇒ Object
13 14 15 |
# File 'lib/b_b/builder.rb', line 13 def build structure.flatten.compact.map(&:build).join(" ") end |