Sha256: dfacc9ceb5f735eb45d82acfbccea59db800021f2cd9e4a0a6a277b752bc62ff
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'rails_clafer/gcard' require 'rails_clafer/card' require 'rails_clafer/clafer_element' require 'rails_clafer/association' require 'rails_clafer/ref_clafer' require 'rails_clafer/sub_clafer' module RailsClafer class ClaferModel class << self def init(settings) end def assoc_src @assoc_src ||= associations.inject({}) do |result, assoc| (result[assoc.src] ||= []) << assoc result end end def assoc_dst @assoc_dst ||= associations.inject({}) do |result, assoc| (result[assoc.dst] ||= []) << assoc result end end def abstract_clafers @abstract_clafers ||= clafers.select{|clafer| clafer.is_abstract?} end def clafer_by_name(name) @clafer_map ||= Hash[clafers.collect {|clafer| [clafer.name, clafer]}] @clafer_map[name] end 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 def clafers @clafers ||= ClaferElement.from_rails_models rails_models end def rails_models @rails_models ||= ActiveRecord::Base.descendants end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_clafer-0.1.2 | lib/rails_clafer/clafer_model.rb |