Class: ModestModel::Base
- Inherits:
-
Object
- Object
- ModestModel::Base
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation, CombinedAttr
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Conversion, ActiveModel::Serialization, ActiveModel::Validations, Validators
- Defined in:
- lib/modest_model/base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #[](attr) ⇒ Object
- #[]=(attr, val) ⇒ Object
- #attributes ⇒ Object
- #attributes=(attributes, options = {}) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Base
constructor
A new instance of Base.
- #persisted? ⇒ Boolean
Methods included from CombinedAttr
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 |
# File 'lib/modest_model/base.rb', line 13 def initialize(attributes = {}, ={}) self.assign_attributes(attributes, ) end |
Class Method Details
.attributes(*names) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/modest_model/base.rb', line 23 def self.attributes(*names) attr_accessor *names define_attribute_methods names self._attributes += names end |
Instance Method Details
#[](attr) ⇒ Object
41 42 43 |
# File 'lib/modest_model/base.rb', line 41 def [] attr attributes[attr.to_s] end |
#[]=(attr, val) ⇒ Object
45 46 47 |
# File 'lib/modest_model/base.rb', line 45 def []= attr, val self.send "#{attr}=", val end |
#attributes ⇒ Object
30 31 32 33 34 35 |
# File 'lib/modest_model/base.rb', line 30 def attributes self._attributes.inject({}) do |hash, attr| hash[attr.to_s] = send(attr) hash end end |
#attributes=(attributes, options = {}) ⇒ Object
37 38 39 |
# File 'lib/modest_model/base.rb', line 37 def attributes= attributes, = {} assign_attributes attributes, = {} end |
#persisted? ⇒ Boolean
49 50 51 |
# File 'lib/modest_model/base.rb', line 49 def persisted? false end |