Class: Rodauth::TemplateInspector::BindingContext

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_prefixObject (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

#dbObject

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_bindingObject

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