Module: StaticModel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/static_model.rb
Overview
Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#[](key) ⇒ Object
Used by AR for fetching attributes.
- #destroyed? ⇒ Boolean
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
- #to_param ⇒ Object
Instance Method Details
#==(other) ⇒ Object
42 43 44 |
# File 'lib/static_model.rb', line 42 def ==(other) other.present? && other.is_a?(self.class) && id == other.id end |
#[](key) ⇒ Object
Used by AR for fetching attributes
Pass it along if we respond to it.
22 23 24 |
# File 'lib/static_model.rb', line 22 def [](key) send(key) if respond_to?(key) # rubocop:disable GitlabSecurity/PublicSend end |
#destroyed? ⇒ Boolean
38 39 40 |
# File 'lib/static_model.rb', line 38 def destroyed? false end |
#new_record? ⇒ Boolean
30 31 32 |
# File 'lib/static_model.rb', line 30 def new_record? false end |
#persisted? ⇒ Boolean
34 35 36 |
# File 'lib/static_model.rb', line 34 def persisted? false end |
#to_param ⇒ Object
26 27 28 |
# File 'lib/static_model.rb', line 26 def to_param id end |