Module: Traits
- Extended by:
- Enumerable, DescendantsListing, Utilities
- Defined in:
- lib/traits/base.rb,
lib/traits/list.rb,
lib/traits/model.rb,
lib/traits/model.rb,
lib/traits/railtie.rb,
lib/traits/version.rb,
lib/traits/attribute.rb,
lib/traits/attribute.rb,
lib/traits/utilities.rb,
lib/traits/model/i18n.rb,
lib/traits/association.rb,
lib/traits/association.rb,
lib/traits/model/naming.rb,
lib/traits/attribute/key.rb,
lib/traits/attribute/type.rb,
lib/traits/model/querying.rb,
lib/traits/association/join.rb,
lib/traits/attribute/naming.rb,
lib/traits/association/macro.rb,
lib/traits/model/inheritance.rb,
lib/traits/association/naming.rb,
lib/traits/attribute/querying.rb,
lib/traits/model/polymorphism.rb,
lib/traits/association/members.rb,
lib/traits/association/through.rb,
lib/traits/descendants_listing.rb,
lib/traits/association/read_only.rb,
lib/traits/attribute/inheritance.rb,
lib/traits/model/essay_shortcuts.rb,
lib/traits/attribute/polymorphism.rb,
lib/traits/association/intermediate.rb,
lib/traits/association/polymorphism.rb,
lib/traits/attribute/essay_shortcuts.rb,
lib/traits/association/essay_shortcuts.rb,
lib/activerecord-traits.rb
Defined Under Namespace
Modules: DescendantsListing, Utilities
Classes: Association, Attribute, AttributeList, Base, List, Model, Railtie, UnidentifiedModelReference
Constant Summary
collapse
- VERSION =
'1.0.3'
Class Method Summary
collapse
Methods included from Utilities
active_record_descendant?, active_record_instance?, retrieve_model_class, valid_active_record_identifier?
active_record_descendants, active_record_descendants_loaded?, excluded_active_record_descendant?, invalidate_loaded_active_record_descendants!, load_active_record_descendants!
Class Method Details
.all ⇒ Object
37
38
39
40
41
|
# File 'lib/activerecord-traits.rb', line 37
def self.all
each_with_object({}) do |traits, memo|
memo[traits.name] = traits
end
end
|
.each(&block) ⇒ Object
33
34
35
|
# File 'lib/activerecord-traits.rb', line 33
def self.each(&block)
active_record_descendants.each { |ar| block.call(ar.traits) }
end
|
.each_attribute(&block) ⇒ Object
43
44
45
|
# File 'lib/activerecord-traits.rb', line 43
def self.each_attribute(&block)
each { |traits| traits.attributes.each(&block) }
end
|
.for(obj) ⇒ Object
29
30
31
|
# File 'lib/activerecord-traits.rb', line 29
def self.for(obj)
retrieve_model_class(obj).traits
end
|
.to_hash ⇒ Object
47
48
49
50
51
|
# File 'lib/activerecord-traits.rb', line 47
def self.to_hash
each_with_object({}) do |traits, memo|
memo[traits.name] = traits.to_hash
end
end
|