Sha256: df4f8856faf0c0450b3704772ab31bebbed6387c6d779fe7ed5168c4e405af0b
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Dottie class Freckle include Methods ## # Creates a new Freckle to wrap the supplied object. def initialize(obj) @_wrapped_object = obj end ## # Returns the wrapped Hash, and raises an error if the wrapped object is # not a Hash. def hash wrapped_object(Hash) end ## # Returns the wrapped Array, and raises an error if the wrapped object is # not an Array. def array wrapped_object(Array) end ## # Returns the wrapped object, and raises an error if a type class is # provided and the wrapped object is not of that type. def wrapped_object(type = nil) if type.nil? || @_wrapped_object.is_a?(type) @_wrapped_object else raise TypeError.new("expected #{type.name} but got #{@_wrapped_object.class.name}") end end def inspect "<Dottie::Freckle #{wrapped_object.inspect}>" end def method_missing(method, *args) wrapped_object.send(method, *args) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dottie-0.0.1 | lib/dottie/freckle.rb |