def token_value(object, options, language)
      # token is an array
      if object.is_a?(Array)
        # if you provided an array, it better have some values
        if object.empty?
          return raise Tr8n::TokenException.new("Invalid array value for a token: #{full_name}")
        end

        # if the first value of an array is an array handle it here
        if object.first.kind_of?(Enumerable)
          return token_array_value(object, options, language)
        end

        # if the first item in the array is an object, process it
        return evaluate_token_method_array(object.first, object, options, language)
      elsif object.is_a?(Hash) 
        # if object is a hash, it must be of a form: {:object => {}, :value => "", :attribute => ""}
        # either value can be passed, or the attribute. attribute will be used first
        if object[:object].nil?
          return raise Tr8n::TokenException.new("Hash token is missing an object key for a token: #{full_name}")
        end

        value = object[:value]

        unless object[:attribute].blank?
          value = object[:object][object[:attribute]]
        end

        if value.blank?
          return raise Tr8n::TokenException.new("Hash object is missing a value or attribute key for a token: #{full_name}")
        end

        object = value
      end

      # simple token
      sanitize_token_value(object, object.to_s, options, language)    
    end
def token_value(object, options, language)
      # token is an array
      if object.is_a?(Array)
        # if you provided an array, it better have some values
        if object.empty?
          return raise Tr8n::TokenException.new("Invalid array value for a token: #{full_name}")
        end

        # if the first value of an array is an array handle it here
        if object.first.kind_of?(Enumerable)
          return token_array_value(object, options, language)
        end

        # if the first item in the array is an object, process it
        return evaluate_token_method_array(object.first, object, options, language)
      elsif object.is_a?(Hash) 
        # if object is a hash, it must be of a form: {:object => {}, :value => "", :attribute => ""}
        # either value can be passed, or the attribute. attribute will be used first
        if object[:object].nil?
          return raise Tr8n::TokenException.new("Hash token is missing an object key for a token: #{full_name}")
        end

        value = object[:value]

        unless object[:attribute].blank?
          value = object[:object][object[:attribute]]
        end

        if value.blank?
          return raise Tr8n::TokenException.new("Hash object is missing a value or attribute key for a token: #{full_name}")
        end

        object = value
      end

      # simple token
      sanitize_token_value(object, object.to_s, options, language)    
    end
def token_value ( object , options , language ) # token is an array if object . is_a? ( Array ) # if you provided an array, it better have some values if object . empty? return raise Tr8n :: TokenException . new ( "Invalid array value for a token: #{full_name}" ) end # if the first value of an array is an array handle it here if object . first . kind_of? ( Enumerable ) return token_array_value ( object , options , language ) end # if the first item in the array is an object, process it return evaluate_token_method_array ( object . first , object , options , language ) elsif object . is_a? ( Hash ) # if object is a hash, it must be of a form: {:object => {}, :value => "", :attribute => ""} # either value can be passed, or the attribute. attribute will be used first if object [ :object ] . nil? return raise Tr8n :: TokenException . new ( "Hash token is missing an object key for a token: #{full_name}" ) end value = object [ :value ] unless object [ :attribute ] . blank? value = object [ :object ] [ object [ :attribute ] ] end if value . blank? return raise Tr8n :: TokenException . new ( "Hash object is missing a value or attribute key for a token: #{full_name}" ) end object = value end # simple token sanitize_token_value ( object , object . to_s , options , language ) end
evaluate all possible methods for the token value and return sanitized result
evaluate all possible methods for the token value and return sanitized result