Class: ActiveRecord::View::Introspection::Abstract Abstract Private
- Inherits:
-
Object
- Object
- ActiveRecord::View::Introspection::Abstract
- Extended by:
- ActiveModel::Callbacks
- Defined in:
- lib/activerecord/view/introspection/abstract.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#arel_cast(value, type, quote_value: true, literalize_type: true) ⇒ Arel::Nodes::NamedFunction("CAST", [Arel::Nodes::As(Arel::Nodes::Quoted, Arel::Nodes::SqlLiteral)])
private
Build a SQL-compliant cast statement.
-
#arel_fn(name, *args) ⇒ Arel::Nodes::NamedFunction
private
Build an Arel function.
-
#arel_quoted(value) ⇒ Arel::Nodes::Quoted
private
Build a quoted string.
- #arel_quoted?(value) ⇒ Boolean private
- #default_connection ⇒ ActiveRecord::ConnectionAdapters::AbstractAdapter private
- #definition_for(view_name, **options) ⇒ String private
- #fetch_view_definition_query(view_name, **options) ⇒ Arel::SelectManager abstract private
- #inspect ⇒ Object private
- #process_view_definition(result) ⇒ String private
- #select_manager ⇒ Arel::SelectManager private
- #views ⇒ <ActiveRecord::View::Introspection::ViewDefinition> abstract private
Instance Method Details
#arel_cast(value, type, quote_value: true, literalize_type: true) ⇒ Arel::Nodes::NamedFunction("CAST", [Arel::Nodes::As(Arel::Nodes::Quoted, Arel::Nodes::SqlLiteral)])
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a SQL-compliant cast statement
69 70 71 72 73 74 75 76 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 69 def arel_cast(value, type, quote_value: true, literalize_type: true) value = arel_quoted(value) if quote_value type = Arel.sql(type) if literalize_type as_expr = Arel::Nodes::As.new value, type arel_fn 'CAST', as_expr end |
#arel_fn(name, *args) ⇒ Arel::Nodes::NamedFunction
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build an Arel function
81 82 83 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 81 def arel_fn(name, *args) Arel::Nodes::NamedFunction.new(name, args) end |
#arel_quoted(value) ⇒ Arel::Nodes::Quoted
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a quoted string
88 89 90 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 88 def arel_quoted(value) arel_quoted?(value) ? value : Arel::Nodes.build_quoted(value) end |
#arel_quoted?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 92 def arel_quoted?(value) value.kind_of? Arel::Nodes::Quoted end |
#default_connection ⇒ ActiveRecord::ConnectionAdapters::AbstractAdapter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 101 102 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 98 def default_connection # :nocov: ActiveRecord::Base.connection # :nocov: end |
#definition_for(view_name, **options) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 27 def definition_for(view_name, **) run_callbacks :fetch_view_definition do result = select_value fetch_view_definition_query(view_name, **) process_view_definition(result).tap do |processed| raise ActiveRecord::View::Error, 'Empty Definition' if raise_error? && processed.blank? end end end |
#fetch_view_definition_query(view_name, **options) ⇒ Arel::SelectManager
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 52 def fetch_view_definition_query(view_name, **) # :nocov: raise NotImplementedError, "Must implement for #{self.class}" # :nocov: end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 58 def inspect # :nocov: "<#{self.class.name}(:raise_error => #{raise_error?})>" # :nocov: end |
#process_view_definition(result) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 44 def process_view_definition(result) result end |
#select_manager ⇒ Arel::SelectManager
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 38 def select_manager Arel::SelectManager.new self end |
#views ⇒ <ActiveRecord::View::Introspection::ViewDefinition>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 |
# File 'lib/activerecord/view/introspection/abstract.rb', line 20 def views end |