Class: Ohm::Types::Base

Inherits:
BasicObject
Extended by:
Forwardable
Defined in:
lib/ohm/contrib/typecast.rb

Direct Known Subclasses

Primitive, Serialized

Defined Under Namespace

Classes: Exception

Constant Summary

@@delegation_blacklist =
[
  :==, :to_s, :initialize, :inspect, :object_id, :__send__, :__id__,
  :respond_to?
]

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) [](value)



39
40
41
42
43
# File 'lib/ohm/contrib/typecast.rb', line 39

def self.[](value)
  return empty  if value.to_s.empty?

  new(value)
end

+ (Object) delegate_to(klass, except = @@delegation_blacklist)



49
50
51
52
# File 'lib/ohm/contrib/typecast.rb', line 49

def self.delegate_to(klass, except = @@delegation_blacklist)
  methods = klass.public_instance_methods.map(&:to_sym) - except
  def_delegators :object, *methods
end

+ (Object) empty



45
46
47
# File 'lib/ohm/contrib/typecast.rb', line 45

def self.empty
  defined?(self::RAW) ? self::RAW.new : nil
end

Instance Method Details

- (Object) inspect



54
55
56
# File 'lib/ohm/contrib/typecast.rb', line 54

def inspect
  @raw.inspect
end