Class: Styleus::Base

Inherits:
Object
  • Object
show all
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

ViewComponent

Class Method Summary collapse

Instance Method Summary collapse

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

#idObject



14
15
16
# File 'app/models/styleus/base.rb', line 14

def id
  nil
end

#to_keyObject

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