Sha256: 38e0fe7079e1645a254505824f24e8fbf50655202f5273604d67bed85b229636

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

# this is primarily for 1.8.7 support
# see http://www.ruby-doc.org/core-2.0/Symbol.html#method-i-empty-3F
unless :locale.respond_to? :empty?
  class Symbol
    def empty?
      self.to_s.empty?
    end
  end
end

module LocaleSetter
  module User
    def self.for(user, available)
      if user && user.respond_to?(locale_method) &&
         user.send(locale_method) && !user.send(locale_method).empty?
        LocaleSetter::Matcher.match user.send(locale_method), available
      end
    end

    def self.locale_method
      LocaleSetter.config.user_locale_method
    end

    def self.locale_method=(method_name)
      warn "Deprecation warning. You should use a new block syntax for configuration."
      LocaleSetter.config.user_locale_method = method_name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locale_setter-0.4.0 lib/locale_setter/user.rb