Module: Informal::ModelNoInit
- Defined in:
- lib/informal/model_no_init.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #attributes=(attrs) ⇒ Object
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
- #to_key ⇒ Object
- #to_model ⇒ Object
- #to_param ⇒ Object
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/informal/model_no_init.rb', line 4 def self.included(klass) klass.class_eval do extend ActiveModel::Naming include ActiveModel::Validations extend ClassMethods end end |
Instance Method Details
#attributes=(attrs) ⇒ Object
20 21 22 |
# File 'lib/informal/model_no_init.rb', line 20 def attributes=(attrs) attrs && attrs.each_pair { |name, value| self.send("#{name}=", value) } end |
#new_record? ⇒ Boolean
28 29 30 |
# File 'lib/informal/model_no_init.rb', line 28 def new_record? true end |
#persisted? ⇒ Boolean
24 25 26 |
# File 'lib/informal/model_no_init.rb', line 24 def persisted? false end |
#to_key ⇒ Object
36 37 38 |
# File 'lib/informal/model_no_init.rb', line 36 def to_key [object_id] end |
#to_model ⇒ Object
32 33 34 |
# File 'lib/informal/model_no_init.rb', line 32 def to_model self end |
#to_param ⇒ Object
40 41 42 |
# File 'lib/informal/model_no_init.rb', line 40 def to_param nil end |