Class: MultiTenant::BaseTenantEnforcementClause

Inherits:
Arel::Nodes::Node
  • Object
show all
Defined in:
lib/activerecord-multi-tenant/query_rewriter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenant_attribute) ⇒ BaseTenantEnforcementClause

Returns a new instance of BaseTenantEnforcementClause.



158
159
160
161
# File 'lib/activerecord-multi-tenant/query_rewriter.rb', line 158

def initialize(tenant_attribute)
  @tenant_attribute = tenant_attribute
  @tenant_model = MultiTenant.multi_tenant_model_for_table(tenant_attribute.relation.table_name)
end

Instance Attribute Details

#tenant_attributeObject (readonly)

Returns the value of attribute tenant_attribute.



157
158
159
# File 'lib/activerecord-multi-tenant/query_rewriter.rb', line 157

def tenant_attribute
  @tenant_attribute
end

Instance Method Details

#to_sObject



163
# File 'lib/activerecord-multi-tenant/query_rewriter.rb', line 163

def to_s; to_sql; end

#to_sqlObject



166
167
168
169
170
# File 'lib/activerecord-multi-tenant/query_rewriter.rb', line 166

def to_sql(*)
  collector = Arel::Collectors::SQLString.new
  collector = @tenant_model.connection.visitor.accept tenant_arel, collector
  collector.value
end

#to_strObject



164
# File 'lib/activerecord-multi-tenant/query_rewriter.rb', line 164

def to_str; to_sql; end