Module: AssociateJsonb::ArelExtensions::Nodes::TableAlias
- Defined in:
- lib/associate_jsonb/arel_extensions/nodes/table_alias.rb
Instance Attribute Summary collapse
-
#store_tracker ⇒ Object
readonly
Returns the value of attribute store_tracker.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #initialize(*args, store_columns: nil) ⇒ Object
- #with_store_tracker(tracker) ⇒ Object
Instance Attribute Details
#store_tracker ⇒ Object (readonly)
Returns the value of attribute store_tracker.
8 9 10 |
# File 'lib/associate_jsonb/arel_extensions/nodes/table_alias.rb', line 8 def store_tracker @store_tracker end |
Instance Method Details
#[](name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/associate_jsonb/arel_extensions/nodes/table_alias.rb', line 20 def [](name) return super unless store_col = store_tracker&.get(name) attr = ::Arel::Nodes::Jsonb::DashArrow. new(self, self[store_col[:store]], store_col[:key]) if cast_as = (store_col[:cast] && store_col[:cast][:sql_type]) attr = ::Arel::Nodes::NamedFunction.new( "CAST", [ attr.as(cast_as) ] ) end Arel::Nodes::Jsonb::Attribute.new(self, name, attr) end |
#initialize(*args, store_columns: nil) ⇒ Object
10 11 12 13 |
# File 'lib/associate_jsonb/arel_extensions/nodes/table_alias.rb', line 10 def initialize(*args, store_columns: nil) @store_columns = store_columns super(*args) end |
#with_store_tracker(tracker) ⇒ Object
15 16 17 18 |
# File 'lib/associate_jsonb/arel_extensions/nodes/table_alias.rb', line 15 def with_store_tracker(tracker) @store_tracker = tracker self end |