Sha256: 02352ea7b1b5daecae9928598754939b316e13a4f3da32afe61ac33d0ab3eb9c
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# encoding: UTF-8 module Rosette module Core module Commands # Mixin that handles configuration and validation of a locale code. # Meant to be mixed into the classes in {Rosette::Core::Commands}. # # @example # class MyCommand < Command # include WithRepoName # include WithLocale # end # # cmd = MyCommand.new(configuration) # .set_repo_name('my_repo') # .set_locale('ja-JP') # # cmd.locale # => 'ja-JP' # cmd.valid? # => true # # cmd.set_locale('foobar') # cmd.valid? # => false # cmd.messages # => { locale: ["Repo 'my_repo' doesn't support the 'foobar' locale"] } module WithLocale attr_reader :locale # Sets the locale code. # # @param [String] locale_code # @return [self] def set_locale(locale_code) @locale = locale_code self end protected def self.included(base) base.validate :locale, type: :locale end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rosette-core-1.0.1 | lib/rosette/core/commands/translations/with_locale.rb |