Class: Dynamicloud::API::Criteria::JoinClause

Inherits:
Condition
  • Object
show all
Defined in:
lib/dynamic_criteria.rb

Overview

This class represents a Join clause

Constant Summary

Constants inherited from Condition

Condition::ROOT, Condition::WITHOUT

Instance Method Summary collapse

Constructor Details

#initialize(join_type, model_id, aliass, join_condition) ⇒ JoinClause

Builds a JoinClause using type, model and compatible condition.

Parameters:

  • join_type

    join type

  • model_id

    target model id

  • aliass

    alias to use with this target model. You don’t need to concatenate the alias in join condition.

  • join_condition

    compatible join condition



65
66
67
68
69
70
# File 'lib/dynamic_criteria.rb', line 65

def initialize(join_type, model_id, aliass, join_condition)
  @join_type = join_type
  @model_id = model_id
  @join_condition = join_condition
  @alias = aliass
end

Instance Method Details

#to_record_string(parent) ⇒ Object

This method will return a String of this condition

Parameters:

  • parent

    this is the parent of this condition

Returns:

  • a json



75
76
77
# File 'lib/dynamic_criteria.rb', line 75

def to_record_string(parent)
  '{ "type": "' + @join_type.to_string + '", "alias": "' + @alias + '", "target": "' + @model_id.to_s + '", "on": "' + @join_condition + '" }'
end