Class: CrossOrigin::Config
- Inherits:
-
Object
- Object
- CrossOrigin::Config
- Defined in:
- lib/cross_origin.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #collection_for(model) ⇒ Object
- #collection_name_for(model) ⇒ Object
-
#initialize(name, options) ⇒ Config
constructor
A new instance of Config.
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, ) @name = name @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
47 48 49 |
# File 'lib/cross_origin.rb', line 47 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
47 48 49 |
# File 'lib/cross_origin.rb', line 47 def @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.[:collection]}" end |