Class: Multitenant::Mysql::Configs::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/multitenant-mysql/configs/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



5
6
7
# File 'lib/multitenant-mysql/configs/base.rb', line 5

def bucket
  @bucket
end

#modelsObject

Returns the value of attribute models.



5
6
7
# File 'lib/multitenant-mysql/configs/base.rb', line 5

def models
  @models
end

Instance Method Details

#bucket_fieldObject



18
19
20
# File 'lib/multitenant-mysql/configs/base.rb', line 18

def bucket_field
  @bucket.field
end

#tenantObject



14
15
16
# File 'lib/multitenant-mysql/configs/base.rb', line 14

def tenant
  @bucket.model
end

#tenant?(model) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/multitenant-mysql/configs/base.rb', line 22

def tenant?(model)
  tenant == model
end

#tenants_bucket(name) {|@bucket| ... } ⇒ Object

Yields:

Raises:



7
8
9
10
11
12
# File 'lib/multitenant-mysql/configs/base.rb', line 7

def tenants_bucket(name)
  raise InvalidBucketError.new('Multitenant::Mysql: invalid bucket') if name.blank?

  @bucket = Bucket.new(name)
  yield(@bucket) if block_given?
end