Module: Perpetuity::RailsModel

Defined in:
lib/perpetuity/rails_model.rb

Defined Under Namespace

Modules: ActiveModelish

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



3
4
5
# File 'lib/perpetuity/rails_model.rb', line 3

def self.included klass
  klass.extend ActiveModelish
end

Instance Method Details

#model_nameObject



19
20
21
# File 'lib/perpetuity/rails_model.rb', line 19

def model_name
  self.class.model_name
end

#persisted?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/perpetuity/rails_model.rb', line 7

def persisted?
  defined? @id
end

#to_keyObject



15
16
17
# File 'lib/perpetuity/rails_model.rb', line 15

def to_key
  [to_param] if persisted?
end

#to_modelObject



23
24
25
# File 'lib/perpetuity/rails_model.rb', line 23

def to_model
  self
end

#to_paramObject



11
12
13
# File 'lib/perpetuity/rails_model.rb', line 11

def to_param
  @id if persisted?
end