Class: ActiveForce::SelectBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_force/select_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selected_fields, query) ⇒ SelectBuilder

Returns a new instance of SelectBuilder.



6
7
8
9
10
11
# File 'lib/active_force/select_builder.rb', line 6

def initialize(selected_fields, query)
  @query = query
  @selected_fields = selected_fields
  @non_nested_query_fields = []
  @nested_query_fields = []
end

Instance Attribute Details

#nested_query_fieldsObject (readonly)

Returns the value of attribute nested_query_fields.



4
5
6
# File 'lib/active_force/select_builder.rb', line 4

def nested_query_fields
  @nested_query_fields
end

#non_nested_query_fieldsObject (readonly)

Returns the value of attribute non_nested_query_fields.



4
5
6
# File 'lib/active_force/select_builder.rb', line 4

def non_nested_query_fields
  @non_nested_query_fields
end

#queryObject (readonly)

Returns the value of attribute query.



4
5
6
# File 'lib/active_force/select_builder.rb', line 4

def query
  @query
end

#selected_fieldsObject (readonly)

Returns the value of attribute selected_fields.



4
5
6
# File 'lib/active_force/select_builder.rb', line 4

def selected_fields
  @selected_fields
end

Instance Method Details

#parseObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_force/select_builder.rb', line 13

def parse
  selected_fields.each do |field|
    case field
    when Symbol
      non_nested_query_fields << query.mappings[field]
    when Hash
      populate_nested_query_fields(field)
    when String
      non_nested_query_fields << field
    end
  end
  {non_nested_query_fields: non_nested_query_fields, nested_query_fields: nested_query_fields}
end