Module: Frenchy::Veneer::ClassMethods

Defined in:
lib/frenchy/veneer.rb

Instance Method Summary collapse

Instance Method Details

#veneer(options = {}) ⇒ Object

Macro to establish a veneer for a given model



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/frenchy/veneer.rb', line 19

def veneer(options={})
  options.stringify_keys!
  @model = options.delete("model") || raise(Frenchy::Error, "Veneer must specify a model")
  extend ActiveModel::Naming

  class_eval do
    def self.model_name
      ActiveModel::Name.new(self, nil, @model.to_s.camelize)
    end
  end
end