class DTK::DSL::Template::Parsing::ParsingError::WrongObjectType

Public Class Methods

new(obj, correct_ruby_types, opts = {}) click to toggle source
Calls superclass method
# File lib/dsl/template/parsing/parsing_error/subclasses.rb, line 29
def initialize(obj, correct_ruby_types, opts = {})
  correct_ruby_types = [correct_ruby_types] unless correct_ruby_types.kind_of?(::Array)
  error_msg = 
    if correct_ruby_types.size == 1
      "The key's value should have type #{correct_ruby_types.first}"
    else
      "The key's value should be one of the types (#{correct_ruby_types.join(' ')})"
    end
  error_msg << (obj.nil? ? ", but has null value" : ", but has type #{input_class_string(obj)}")
  super(error_msg, opts)
end

Private Instance Methods

input_class_string(obj) click to toggle source
# File lib/dsl/template/parsing/parsing_error/subclasses.rb, line 43
def input_class_string(obj)
  if obj.kind_of?(::Hash) 
    'Hash'
  elsif obj.kind_of?(::Array)
    'Array'
  elsif obj.kind_of?(::String)
    'String'
  # elesif ..TODO: should we handle Booleans in special way
  else
    # demodularize
    obj.class.to_s.split('::').last
  end
end