Class: Exwiw::QueryAst::JoinClause
- Inherits:
-
Object
- Object
- Exwiw::QueryAst::JoinClause
- Defined in:
- lib/exwiw/query_ast.rb
Instance Attribute Summary collapse
-
#base_table_name ⇒ Object
readonly
Returns the value of attribute base_table_name.
-
#foreign_key ⇒ Object
readonly
Returns the value of attribute foreign_key.
-
#join_table_name ⇒ Object
readonly
Returns the value of attribute join_table_name.
-
#primary_key ⇒ Object
readonly
Returns the value of attribute primary_key.
-
#where_clauses ⇒ Object
readonly
Returns the value of attribute where_clauses.
Instance Method Summary collapse
-
#initialize(base_table_name:, foreign_key:, join_table_name:, primary_key:, where_clauses: []) ⇒ JoinClause
constructor
A new instance of JoinClause.
- #to_h ⇒ Object
Constructor Details
#initialize(base_table_name:, foreign_key:, join_table_name:, primary_key:, where_clauses: []) ⇒ JoinClause
Returns a new instance of JoinClause.
8 9 10 11 12 13 14 |
# File 'lib/exwiw/query_ast.rb', line 8 def initialize(base_table_name:, foreign_key:, join_table_name:, primary_key:, where_clauses: []) @base_table_name = base_table_name @foreign_key = foreign_key @join_table_name = join_table_name @primary_key = primary_key @where_clauses = where_clauses end |
Instance Attribute Details
#base_table_name ⇒ Object (readonly)
Returns the value of attribute base_table_name.
6 7 8 |
# File 'lib/exwiw/query_ast.rb', line 6 def base_table_name @base_table_name end |
#foreign_key ⇒ Object (readonly)
Returns the value of attribute foreign_key.
6 7 8 |
# File 'lib/exwiw/query_ast.rb', line 6 def foreign_key @foreign_key end |
#join_table_name ⇒ Object (readonly)
Returns the value of attribute join_table_name.
6 7 8 |
# File 'lib/exwiw/query_ast.rb', line 6 def join_table_name @join_table_name end |
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
6 7 8 |
# File 'lib/exwiw/query_ast.rb', line 6 def primary_key @primary_key end |
#where_clauses ⇒ Object (readonly)
Returns the value of attribute where_clauses.
6 7 8 |
# File 'lib/exwiw/query_ast.rb', line 6 def where_clauses @where_clauses end |
Instance Method Details
#to_h ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/exwiw/query_ast.rb', line 16 def to_h hash = { base_table_name: base_table_name, foreign_key: foreign_key, join_table_name: join_table_name, primary_key: primary_key, } if where_clauses.size.positive? hash[:where_clauses] = where_clauses.map { |wc| wc.is_a?(String) ? wc : wc.to_h } end hash end |