Class: ActiveRecordExtended::QueryMethods::Json::JsonChain

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/active_record_extended/query_methods/json.rb

Constant Summary collapse

DEFAULT_ALIAS =
'"results"'

Constants included from Utilities

Utilities::A_TO_Z_KEYS

Instance Method Summary collapse

Methods included from Utilities

#double_quote, #flatten_safely, #flatten_to_sql, #from_clause_constructor, #key_generator, #literal_key, #nested_alias_escape, #pipe_cte_with!, #to_arel_sql, #wrap_with_array

Constructor Details

#initialize(scope) ⇒ JsonChain

Returns a new instance of JsonChain.



18
19
20
# File 'lib/active_record_extended/query_methods/json.rb', line 18

def initialize(scope)
  @scope = scope
end

Instance Method Details

#json_build_literal!(*args) ⇒ Object



37
38
39
40
# File 'lib/active_record_extended/query_methods/json.rb', line 37

def json_build_literal!(*args)
  options = json_object_options(args).slice(:values, :col_alias)
  build_json_literal(Arel::Nodes::JsonBuildObject, **options)
end

#json_build_object!(*args) ⇒ Object



27
28
29
30
# File 'lib/active_record_extended/query_methods/json.rb', line 27

def json_build_object!(*args)
  options = json_object_options(args).except!(:values)
  build_json_object(Arel::Nodes::JsonBuildObject, **options)
end

#jsonb_build_literal!(*args) ⇒ Object



42
43
44
45
# File 'lib/active_record_extended/query_methods/json.rb', line 42

def jsonb_build_literal!(*args)
  options = json_object_options(args).slice(:values, :col_alias)
  build_json_literal(Arel::Nodes::JsonbBuildObject, **options)
end

#jsonb_build_object!(*args) ⇒ Object



32
33
34
35
# File 'lib/active_record_extended/query_methods/json.rb', line 32

def jsonb_build_object!(*args)
  options = json_object_options(args).except!(:values)
  build_json_object(Arel::Nodes::JsonbBuildObject, **options)
end

#row_to_json!(**args, &block) ⇒ Object



22
23
24
25
# File 'lib/active_record_extended/query_methods/json.rb', line 22

def row_to_json!(**args, &block)
  options = json_object_options(args).except(:values, :value)
  build_row_to_json(**options, &block)
end