class Verifier::Scope
Provides the scope for I18n translations of verification errors
@api private
Attributes
method[R]
object[R]
Public Class Methods
new(object, method)
click to toggle source
Initializes a new instance
@param [Object] object
the object whose method should be verified
@param [Symbol] method
the name of the method to be verified
@return [undefined]
# File lib/verifier/scope.rb, line 19 def initialize(object, method) @object, @method = object, method end
Public Instance Methods
full()
click to toggle source
Returns a scope for translations of {#method} verification errors
@return [Array<Symbol>]
# File lib/verifier/scope.rb, line 33 def full @full ||= short + [method.to_sym] end
short()
click to toggle source
Returns a scope for all translations of {#object} verification errors
@return [Array<Symbol>]
# File lib/verifier/scope.rb, line 26 def short @short ||= [:verifier, name, type] end
tag()
click to toggle source
Returns a tag (# or .) for the method
@return [<String>]
# File lib/verifier/scope.rb, line 40 def tag (type == :class) ? "." : "#" end
Private Instance Methods
name()
click to toggle source
# File lib/verifier/scope.rb, line 52 def name @name ||= object_class_name.split("::").map(&:snake_case).join("/").to_sym end
object_class_name()
click to toggle source
# File lib/verifier/scope.rb, line 56 def object_class_name object.class.name end
type()
click to toggle source
# File lib/verifier/scope.rb, line 48 def type @type ||= object.is_a?(Class) ? :class : :instance end