Class: AtomicJson::QueryBuilder
- Inherits:
-
Object
- Object
- AtomicJson::QueryBuilder
- Includes:
- JsonQueryHelpers
- Defined in:
- lib/atomic_json/query_builder.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #build(attributes, touch) ⇒ Object
-
#initialize(record, connection) ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
Methods included from JsonQueryHelpers
#concatenation, #jsonb_quote_keys, #jsonb_quote_value
Constructor Details
#initialize(record, connection) ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
14 15 16 17 |
# File 'lib/atomic_json/query_builder.rb', line 14 def initialize(record, connection) @record = record @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/atomic_json/query_builder.rb', line 10 def connection @connection end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
10 11 12 |
# File 'lib/atomic_json/query_builder.rb', line 10 def record @record end |
Instance Method Details
#build(attributes, touch) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/atomic_json/query_builder.rb', line 19 def build(attributes, touch) <<~SQL UPDATE #{quote_table_name(record.class.table_name)} SET #{build_set_subquery(attributes, touch)} WHERE id = #{quote(record.id)}; SQL end |