Method: Forecasting::Models::Base.modeled
- Defined in:
- lib/forecasting/models/base.rb
.modeled(opts = {}) ⇒ Object
Class method to define nested resources for a record.
It needs to be used like this:
class Project < Base
modeled client: Client
...
end
57 58 59 60 61 62 63 64 |
# File 'lib/forecasting/models/base.rb', line 57 def self.modeled(opts = {}) opts.each do |attribute_name, model| attribute_name_string = attribute_name.to_s define_method(attribute_name_string) do @models[attribute_name_string] ||= model.new(@attributes[attribute_name_string] || {}, forecast_client: forecast_client) end end end |