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

Returns a new instance of Config.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#collection_for(model) ⇒ Object



58
59
60
# File 'lib/cross_origin.rb', line 58

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

#collection_name_for(model) ⇒ Object



54
55
56
# File 'lib/cross_origin.rb', line 54

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