lib/mls.rb in mls-1.5.0 vs lib/mls.rb in mls-1.5.1

- old
+ new

@@ -1,6 +1,9 @@ +require 'phony' require 'sunstone' +require 'arel/extensions' +require 'bcrypt' module MLS API_VERSION = '0.1.0' @@ -96,12 +99,16 @@ end def find(*ids) friendly = -> (id) { id.respond_to?(:to_i) && id.to_i.to_s != id.to_s } return super if ids.size > 1 || !ids.all? { |x| friendly.call(x) } - - find_by_slug!(ids.first) + + if ids.first.include?("@") + self.filter(email_addresses: {address: ids.first}).first + else + find_by_slug!(ids.first) + end end end end @@ -145,34 +152,9 @@ extend ActiveSupport::Concern included do belongs_to :avatar, :class_name => 'Image' - end - - def avatar_url(options={}) - return nil unless avatar_hash_key - - options.reverse_merge!({ - :style => nil, - :bg => nil, - :protocol => 'https', - :format => "jpg", - :host => MLS.image_host - }); - - url_params = { s: options[:style], bg: options[:bg] }.select{ |k, v| v } - - if options[:protocol] == :relative # Protocol Relative - result = '//' - else options[:protocol] - result = "#{options[:protocol]}://" - end - - result += "#{options[:host]}/#{avatar_hash_key}.#{options[:format]}" - result += "?#{url_params.to_param}" if url_params.size > 0 - - result end end Dir.glob(File.join(File.dirname(__FILE__), 'mls', '*.rb'), &method(:require))