Class: Rodauth::TemplateInspector::BindingContext
- Inherits:
-
Object
- Object
- Rodauth::TemplateInspector::BindingContext
- Defined in:
- lib/rodauth/template_inspector.rb
Overview
Binding context for ERB evaluation
Provides minimal methods needed for ERB template evaluation without requiring a full database connection or Rodauth instance.
Defined Under Namespace
Classes: MockDatabase
Instance Attribute Summary collapse
-
#table_prefix ⇒ Object
readonly
Returns the value of attribute table_prefix.
Instance Method Summary collapse
-
#db ⇒ Object
Mock database object for template evaluation.
-
#get_binding ⇒ Object
Get binding for ERB evaluation.
-
#initialize(table_prefix, db_type) ⇒ BindingContext
constructor
A new instance of BindingContext.
-
#pluralize(word) ⇒ Object
Pluralize a word using dry-inflector.
Constructor Details
#initialize(table_prefix, db_type) ⇒ BindingContext
Returns a new instance of BindingContext.
85 86 87 88 89 |
# File 'lib/rodauth/template_inspector.rb', line 85 def initialize(table_prefix, db_type) @table_prefix = table_prefix @db_type = db_type @inflector = Dry::Inflector.new end |
Instance Attribute Details
#table_prefix ⇒ Object (readonly)
Returns the value of attribute table_prefix.
83 84 85 |
# File 'lib/rodauth/template_inspector.rb', line 83 def table_prefix @table_prefix end |
Instance Method Details
#db ⇒ Object
Mock database object for template evaluation
Templates check db.database_type and db.supports_partial_indexes? to generate database-specific code.
100 101 102 |
# File 'lib/rodauth/template_inspector.rb', line 100 def db @db ||= MockDatabase.new(@db_type) end |
#get_binding ⇒ Object
Get binding for ERB evaluation
105 106 107 |
# File 'lib/rodauth/template_inspector.rb', line 105 def get_binding binding end |
#pluralize(word) ⇒ Object
Pluralize a word using dry-inflector
92 93 94 |
# File 'lib/rodauth/template_inspector.rb', line 92 def pluralize(word) @inflector.pluralize(word.to_s) end |