Module: StaticModel

Extended by:
ActiveSupport::Concern
Included in:
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.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object


40
41
42
43
44
45
46
# File 'lib/static_model.rb', line 40

def ==(other)
  if other.is_a? ::StaticModel
    id == other.id
  else
    super
  end
end

#[](key) ⇒ Object

Used by AR for fetching attributes

Pass it along if we respond to it.


20
21
22
# File 'lib/static_model.rb', line 20

def [](key)
  send(key) if respond_to?(key)
end

#destroyed?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/static_model.rb', line 36

def destroyed?
  false
end

#new_record?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/static_model.rb', line 28

def new_record?
  false
end

#persisted?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/static_model.rb', line 32

def persisted?
  false
end

#to_paramObject


24
25
26
# File 'lib/static_model.rb', line 24

def to_param
  id
end