Module: StaticModel

Extended by:
ActiveSupport::Concern
Included in:
Ci::Group, Commit, WikiPage
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

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

Returns:

  • (Boolean)


38
39
40
# File 'lib/static_model.rb', line 38

def destroyed?
  false
end

#new_record?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/static_model.rb', line 30

def new_record?
  false
end

#persisted?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/static_model.rb', line 34

def persisted?
  false
end

#to_paramObject



26
27
28
# File 'lib/static_model.rb', line 26

def to_param
  id
end