Class: Models::Base
- Inherits:
-
Object
- Object
- Models::Base
- Defined in:
- lib/bob/models/base.rb
Direct Known Subclasses
CompanyField, CompanyList, Employee, EquityGrant, OnboardingWizard, Salary, TimeOff, VariablePayment
Instance Method Summary collapse
-
#initialize(raw) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(raw) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 12 13 |
# File 'lib/bob/models/base.rb', line 5 def initialize(raw) attributes = Bob::Util.underscorize_hash(raw) attributes.each do |k, v| instance_variable_set("@#{k}", v.is_a?(Hash) ? Models::Base.new(v) : v) self.class.send(:define_method, k, proc { instance_variable_get("@#{k}") }) self.class.send(:define_method, "#{k}=", proc { |val| instance_variable_set("@#{k}", val) }) end end |