Class: RailsClafer::ClaferModel
- Inherits:
-
Object
- Object
- RailsClafer::ClaferModel
- Defined in:
- lib/rails_clafer/clafer_model.rb
Class Method Summary collapse
- .abstract_clafers ⇒ Object
- .assoc_dst ⇒ Object
- .assoc_src ⇒ Object
- .associations ⇒ Object
- .clafer_by_name(name) ⇒ Object
- .claferize_name(class_name) ⇒ Object
- .clafers ⇒ Object
- .init(settings) ⇒ Object
- .rails_models ⇒ Object
Class Method Details
.abstract_clafers ⇒ Object
30 31 32 |
# File 'lib/rails_clafer/clafer_model.rb', line 30 def abstract_clafers @abstract_clafers ||= clafers.select{|clafer| clafer.is_abstract?} end |
.assoc_dst ⇒ Object
23 24 25 26 27 28 |
# File 'lib/rails_clafer/clafer_model.rb', line 23 def assoc_dst @assoc_dst ||= associations.inject({}) do |result, assoc| (result[assoc.dst] ||= []) << assoc result end end |
.assoc_src ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rails_clafer/clafer_model.rb', line 16 def assoc_src @assoc_src ||= associations.inject({}) do |result, assoc| (result[assoc.src] ||= []) << assoc result end end |
.associations ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/rails_clafer/clafer_model.rb', line 39 def associations @associations ||= rails_models.collect { |model| model.reflect_on_all_associations.select { |ar_assoc| !ar_assoc.belongs_to? }.collect{ |ar_assoc| Association.from_ar_assoc(model, ar_assoc) } }.flatten end |
.clafer_by_name(name) ⇒ Object
34 35 36 37 |
# File 'lib/rails_clafer/clafer_model.rb', line 34 def clafer_by_name(name) @clafer_map ||= Hash[clafers.collect {|clafer| [clafer.name, clafer]}] @clafer_map[name] end |
.claferize_name(class_name) ⇒ Object
57 58 59 |
# File 'lib/rails_clafer/clafer_model.rb', line 57 def claferize_name(class_name) class_name.to_s.gsub("::", "__") end |
.clafers ⇒ Object
49 50 51 |
# File 'lib/rails_clafer/clafer_model.rb', line 49 def clafers @clafers ||= ClaferElement.from_rails_models rails_models end |
.init(settings) ⇒ Object
12 13 14 |
# File 'lib/rails_clafer/clafer_model.rb', line 12 def init(settings) end |
.rails_models ⇒ Object
53 54 55 |
# File 'lib/rails_clafer/clafer_model.rb', line 53 def rails_models @rails_models ||= ActiveRecord::Base.descendants end |