Class: Bright::Model
Direct Known Subclasses
Address, Contact, EmailAddress, Enrollment, PhoneNumber, School, Student
Class Method Summary collapse
Instance Method Summary collapse
- #assign_attributes(new_attributes) ⇒ Object
-
#initialize(attributes = {}) ⇒ Model
constructor
A new instance of Model.
- #to_json ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Model
Returns a new instance of Model.
5 6 7 8 9 |
# File 'lib/bright/model.rb', line 5 def initialize(attributes={}) assign_attributes(attributes) if attributes super() end |
Class Method Details
.attribute_names ⇒ Object
21 22 23 |
# File 'lib/bright/model.rb', line 21 def self.attribute_names @attribute_names end |
Instance Method Details
#assign_attributes(new_attributes) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/bright/model.rb', line 11 def assign_attributes(new_attributes) if !new_attributes.is_a?(Hash) raise ArgumentError, "When assigning attributes, you must pass a hash as an argument." end return if new_attributes.empty? attributes = Hash[new_attributes.collect{|k,v| [k.to_sym, v]}] _assign_attributes(attributes) end |