Module: Celerity::ShortInspect

Included in:
Container
Defined in:
lib/celerity/short_inspect.rb

Instance Method Summary collapse

Instance Method Details

#short_inspect(opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/celerity/short_inspect.rb', line 4

def short_inspect(opts)
  if excluded_ivars = opts[:exclude]
    ivars = (instance_variables - excluded_ivars)
  elsif included_ivars = opts[:include]
    ivars = included_ivars
  else
    raise ArgumentError, "unknown arg: #{opts.inspect}"
  end

  ivars.map! { |ivar| "#{ivar}=#{instance_variable_get(ivar).inspect}" }
  '#<%s:0x%s %s>' % [self.class.name, self.hash.to_s(16), ivars.join(" ")]
end