Sha256: e9f72480e4400cf01c477e19a47279eee83fb03ac1dbae721245c2a832e48c7d
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 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 def claferize_name(class_name) class_name.to_s.gsub("::", "__") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_clafer-0.1.7 | lib/rails_clafer/clafer_model.rb |