class NexosisApi::Join

class to hold a join defintion initialized by a hash of join values @since 1.2.0

Attributes

column_options[RW]

The optional column definition for the join which defines how columns should be used from the joined dataset @return [Array of NexosisApi::ColumnOptions] column options definition

join_target[RW]

The details of the data source that will be participating in the join @return [Object] details of the join target

joins[RW]

Optional additional data source to be joined to this data source @return [Array of NexosisApi::Join] zero or more additional joins

Public Class Methods

new(join_hash) click to toggle source
# 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

Public Instance Methods

to_hash() click to toggle source

provides a custom hash which can be converted to json matching api request

# File lib/nexosis_api/join.rb, line 41
def to_hash
  hash = join_target.to_hash
  if column_options.nil? == false
    hash['columnOptions'] = {}
    column_options.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() click to toggle source

gets a json represenation which can be used in api request

# File lib/nexosis_api/join.rb, line 59
def to_json
  to_hash.to_json
end