Method: Governor::Mapping#initialize

Defined in:
lib/governor/mapping.rb

#initialize(resource, options = {}) ⇒ Mapping

Returns a new instance of Mapping.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/governor/mapping.rb', line 6

def initialize(resource, options = {})
  @plural   = (options[:as] ? "#{options[:as]}_#{resource}" : resource).to_sym
  @singular = (options[:singular] || @plural.to_s.singularize).to_sym
  
  @class_name = (options[:class_name] || resource.to_s.classify).to_s
  @ref = defined?(ActiveSupport::Dependencies::ClassCache) ?
    ActiveSupport::Dependencies::Reference.store(@class_name) :
    ActiveSupport::Dependencies.ref(@class_name)
  
  @path = (options[:path] || resource).to_s
  @path_prefix = options[:path_prefix]
  
  @controller = options[:controller] || 'governor/articles'
end