Module: Informal::ModelNoInit

Defined in:
lib/informal/model_no_init.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
9
# File 'lib/informal/model_no_init.rb', line 4

def self.included(klass)
  klass.class_eval do
    extend  ActiveModel::Naming
    include ActiveModel::Validations
  end
end

Instance Method Details

#attributes=(attrs) ⇒ Object



11
12
13
# File 'lib/informal/model_no_init.rb', line 11

def attributes=(attrs)
  attrs.each_pair { |name, value| self.send("#{name}=", value) }
end

#new_record?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/informal/model_no_init.rb', line 19

def new_record?
  true
end

#persisted?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/informal/model_no_init.rb', line 15

def persisted?
  false
end

#to_keyObject



27
28
29
# File 'lib/informal/model_no_init.rb', line 27

def to_key
  [object_id]
end

#to_modelObject



23
24
25
# File 'lib/informal/model_no_init.rb', line 23

def to_model
  self
end

#to_paramObject



31
32
33
# File 'lib/informal/model_no_init.rb', line 31

def to_param
  nil
end