Class: CrossOrigin::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cross_origin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Config



41
42
43
44
# File 'lib/cross_origin.rb', line 41

def initialize(name, options)
  @name = name
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



39
40
41
# File 'lib/cross_origin.rb', line 39

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



39
40
41
# File 'lib/cross_origin.rb', line 39

def options
  @options
end

Instance Method Details

#collection_for(model) ⇒ Object



50
51
52
# File 'lib/cross_origin.rb', line 50

def collection_for(model)
  (Mongoid::Clients.clients[name] || Mongoid.default_client)[collection_name_for(model)]
end

#collection_name_for(model) ⇒ Object



46
47
48
# File 'lib/cross_origin.rb', line 46

def collection_name_for(model)
  "#{name}_#{model.mongoid_root_class.storage_options_defaults[:collection]}"
end