Class: ModestModel::Base
- Inherits:
-
Object
- Object
- ModestModel::Base
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Conversion, ActiveModel::Serialization, ActiveModel::Validations, Validators
- Defined in:
- lib/modest_model/base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #persisted? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 |
# File 'lib/modest_model/base.rb', line 12 def initialize(attributes = {}) attributes.each do |attr, value| self.send("#{attr}=", value) end unless attributes.blank? end |
Class Method Details
.attributes(*names) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/modest_model/base.rb', line 24 def self.attributes(*names) attr_accessor *names define_attribute_methods names self._attributes += names end |
Instance Method Details
#attributes ⇒ Object
31 32 33 34 35 36 |
# File 'lib/modest_model/base.rb', line 31 def attributes self._attributes.inject({}) do |hash, attr| hash[attr.to_s] = send(attr) hash end end |
#persisted? ⇒ Boolean
38 39 40 |
# File 'lib/modest_model/base.rb', line 38 def persisted? false end |