Module: DataBindings::Adapters::Ruby

Included in:
BSON, JSON, Params, TNetstring, XML, YAML
Defined in:
lib/data_bindings/adapters/ruby.rb

Defined Under Namespace

Classes: RubyArrayAdapter, RubyObjectAdapter

Instance Method Summary collapse

Instance Method Details

#from_ruby(obj) ⇒ RubyObjectAdapter, RubyArrayAdapter

Constructs a wrapped object from an Array or Hash

Parameters:

  • obj (Array, Hash)

    The Ruby array or hash

Returns:



8
9
10
11
12
13
14
# File 'lib/data_bindings/adapters/ruby.rb', line 8

def from_ruby(obj)
  case obj
  when Array then from_ruby_array(obj)
  when Hash  then from_ruby_hash(obj)
  else            obj
  end
end

#from_ruby_array(a) ⇒ Object



21
22
23
# File 'lib/data_bindings/adapters/ruby.rb', line 21

def from_ruby_array(a)
  binding_class(RubyArrayAdapter).new(self, a)
end

#from_ruby_hash(h) ⇒ Object Also known as: from_ruby_object



16
17
18
# File 'lib/data_bindings/adapters/ruby.rb', line 16

def from_ruby_hash(h)
  binding_class(RubyObjectAdapter).new(self, h)
end