Class: Traits::Model
- Includes:
- EssayShortcuts, I18n, Inheritance, Naming, Polymorphism, Querying
- Defined in:
- lib/traits/model.rb,
lib/traits/model.rb,
lib/traits/model/i18n.rb,
lib/traits/model/naming.rb,
lib/traits/model/querying.rb,
lib/traits/model/inheritance.rb,
lib/traits/model/polymorphism.rb,
lib/traits/model/essay_shortcuts.rb
Defined Under Namespace
Modules: EssayShortcuts, I18n, Inheritance, Naming, Polymorphism, Querying
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
- #descendants ⇒ Object
-
#initialize(model_class) ⇒ Model
constructor
A new instance of Model.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods included from I18n
Methods included from EssayShortcuts
Methods included from Querying
#arel, #connection, #primary_key_attribute, #primary_key_name, #quoted_table_name, #table_name
Methods included from Polymorphism
Methods included from Inheritance
#inheritance_attribute, #inheritance_attribute_name, #inheritance_base, #inheritance_base?, #inheritance_chain, #inheritance_derived?, #uses_inheritance?
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.
30 31 32 |
# File 'lib/traits/model.rb', line 30 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.
25 26 27 |
# File 'lib/traits/model.rb', line 25 def model_class @model_class end |
Instance Method Details
#associations ⇒ Object
38 39 40 |
# File 'lib/traits/model.rb', line 38 def associations @associations ||= inspect_associations end |
#attributes ⇒ Object
34 35 36 |
# File 'lib/traits/model.rb', line 34 def attributes @attributes ||= inspect_attributes end |
#descendants ⇒ Object
53 54 55 56 |
# File 'lib/traits/model.rb', line 53 def descendants Traits.load_active_record_descendants! active_record.descendants end |
#to_hash ⇒ Object
46 47 48 49 50 51 |
# File 'lib/traits/model.rb', line 46 def to_hash super.merge!( attributes: attributes.to_hash, associations: associations.to_hash ) end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/traits/model.rb', line 42 def to_s class_name end |