Sha256: 732796e50b713801893b83b0efc05b2187a34938e3d77999e670c7d4d9fd0fb8

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

module Findable
  module Associations
    class 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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
findable-0.1.1 lib/findable/associations/utils.rb
findable-0.1.0 lib/findable/associations/utils.rb