Sha256: b8e61ccb40cc8b6d5efe410566ab390626f44b8d24263f6f8b91102a343b6ace
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
module Findable module Associations module Utils def self.model_for(name, options = {}) unless model_name = options[:class_name].presence name = options[:collection] ? name.to_s.singularize : name.to_s model_name = name.camelize end if options[:safe] model_name.try(:safe_constantize) else model_name.constantize end end def self.parse_args(args) copied = args.dup options = copied.extract_options! [copied.first, options] end def self.add_reflection(macro, name, options, ar) reflection = ActiveRecord::Reflection.create( macro.to_sym, name.to_sym, nil, options, ar ) ActiveRecord::Reflection.add_reflection(ar, name.to_sym, reflection) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
findable-0.2.2 | lib/findable/associations/utils.rb |