Class: Traits::Model
- Includes:
- EssayShortcuts, Naming, Polymorphism, Querying, STI
- Defined in:
- lib/traits/model.rb,
lib/traits/model.rb,
lib/traits/concerns/model/sti.rb,
lib/traits/concerns/model/naming.rb,
lib/traits/concerns/model/querying.rb,
lib/traits/concerns/model/polymorphism.rb,
lib/traits/concerns/model/essay_shortcuts.rb
Defined Under Namespace
Modules: EssayShortcuts, Naming, Polymorphism, Querying, STI
Instance Attribute Summary collapse
-
#model_class ⇒ Object
(also: #active_record, #klass)
readonly
Returns the value of attribute model_class.
Instance Method Summary collapse
- #associations ⇒ Object
- #attributes ⇒ Object
-
#initialize(model_class) ⇒ Model
constructor
A new instance of Model.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods included from EssayShortcuts
Methods included from Querying
#arel, #connection, #primary_key_name, #quoted_table_name, #table_name
Methods included from Polymorphism
Methods included from STI
#sti_attribute_name, #sti_base?, #sti_chain, #sti_derived?, #uses_sti?
Methods included from Naming
#class_name, #lookup_name, #name, #plural_name, #resource_name
Constructor Details
#initialize(model_class) ⇒ Model
Returns a new instance of Model.
25 26 27 |
# File 'lib/traits/model.rb', line 25 def initialize(model_class) @model_class = model_class end |
Instance Attribute Details
#model_class ⇒ Object (readonly) Also known as: active_record, klass
Returns the value of attribute model_class.
20 21 22 |
# File 'lib/traits/model.rb', line 20 def model_class @model_class end |
Instance Method Details
#associations ⇒ Object
33 34 35 |
# File 'lib/traits/model.rb', line 33 def associations @associations ||= inspect_associations end |
#attributes ⇒ Object
29 30 31 |
# File 'lib/traits/model.rb', line 29 def attributes @attributes ||= inspect_attributes end |
#to_hash ⇒ Object
41 42 43 44 45 46 |
# File 'lib/traits/model.rb', line 41 def to_hash super.merge!( attributes: attributes.to_hash, associations: associations.to_hash ) end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/traits/model.rb', line 37 def to_s class_name end |