Class: Styleus::Base
- Inherits:
-
Object
- Object
- Styleus::Base
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Serialization
- Defined in:
- app/models/styleus/base.rb
Overview
Provides a basic model, with attribute and naming capabilities. TODO: replace with ActiveModel::Model or something like that
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(attributes) ⇒ Base
constructor
A new instance of Base.
-
#to_key ⇒ Object
as implemented as in ActiveRecord.
Constructor Details
#initialize(attributes) ⇒ Base
Returns a new instance of Base.
10 11 12 |
# File 'app/models/styleus/base.rb', line 10 def initialize(attributes) @attributes = attributes end |
Class Method Details
.with_attributes(*attribute_names) ⇒ Object
31 32 33 |
# File 'app/models/styleus/base.rb', line 31 def with_attributes(*attribute_names) define_attribute_methods attribute_names.map(&:to_s) end |
Instance Method Details
#id ⇒ Object
14 15 16 |
# File 'app/models/styleus/base.rb', line 14 def id nil end |
#to_key ⇒ Object
as implemented as in ActiveRecord
19 20 21 22 |
# File 'app/models/styleus/base.rb', line 19 def to_key key = self.id [key] if key end |