Class: NexosisApi::Join
- Inherits:
-
Object
- Object
- NexosisApi::Join
- Defined in:
- lib/nexosis_api/join.rb
Overview
class to hold a join defintion initialized by a hash of join values
Instance Attribute Summary collapse
-
#column_options ⇒ Array of NexosisApi::ColumnOptions
The optional column definition for the join which defines how columns should be used from the joined dataset.
-
#join_target ⇒ Object
The details of the data source that will be participating in the join.
-
#joins ⇒ Array of NexosisApi::Join
Optional additional data source to be joined to this data source.
Instance Method Summary collapse
-
#initialize(join_hash) ⇒ Join
constructor
A new instance of Join.
-
#to_hash ⇒ Object
provides a custom hash which can be converted to json matching api request.
-
#to_json ⇒ Object
gets a json represenation which can be used in api request.
Constructor Details
#initialize(join_hash) ⇒ Join
Returns a new instance of Join.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nexosis_api/join.rb', line 7 def initialize(join_hash) join_hash.each do |k, v| if k == 'dataSet' @join_target = NexosisApi::DatasetJoinTarget.new(v) unless v.nil? elsif k == 'calendar' @join_target = NexosisApi::CalendarJoinTarget.new(v) unless v.nil? elsif k == 'columnOptions' next if v.nil? @column_options = v.map do |key, option| NexosisApi::ColumnOptions.new(key, option) end elsif k == 'joins' next if v.nil? @joins = v.map do |join| NexosisApi::Join.new(join) end end end end |
Instance Attribute Details
#column_options ⇒ Array of NexosisApi::ColumnOptions
The optional column definition for the join which defines how columns should be used from the joined dataset
34 35 36 |
# File 'lib/nexosis_api/join.rb', line 34 def @column_options end |
#join_target ⇒ Object
The details of the data source that will be participating in the join
29 30 31 |
# File 'lib/nexosis_api/join.rb', line 29 def join_target @join_target end |
#joins ⇒ Array of NexosisApi::Join
Optional additional data source to be joined to this data source
38 39 40 |
# File 'lib/nexosis_api/join.rb', line 38 def joins @joins end |
Instance Method Details
#to_hash ⇒ Object
provides a custom hash which can be converted to json matching api request
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nexosis_api/join.rb', line 41 def to_hash hash = join_target.to_hash if .nil? == false hash['columnOptions'] = {} .each do |column| hash['columnOptions'].merge!(column.to_hash) end end if joins.nil? == false hash['joins'] = [] joins.each do |join| hash['joins'] << join.to_hash end end hash end |
#to_json ⇒ Object
gets a json represenation which can be used in api request
59 60 61 |
# File 'lib/nexosis_api/join.rb', line 59 def to_json to_hash.to_json end |