Sha256: 63127590cebace5c77e9dc0112eb87eaf51847ac68fd2d0c2931dab1e0df9881

Contents?: true

Size: 605 Bytes

Versions: 23

Compression:

Stored size: 605 Bytes

Contents

$:.push 'lib'; require 'transcriber'

module Upcasing
  def self.call(keys)
    keys.map {|key| key.to_s.upcase}
  end
end

module Camelizing
  def self.call(keys)
    keys.map {|key| key.to_s.camelize}
  end
end

class Customer < Transcriber::Resource
  convert_input_keys Upcasing
  property :login
  embeds_one :product
end

class Product < Transcriber::Resource
  convert_input_keys Camelizing
  property :unit_price, type: Float
end

@root = Customer.parse({"LOGIN" => 'jackiechan2010', "PRODUCT" => {"UnitPrice" => 29.9}}).first

puts "root:     #{@root.inspect}"
puts "resource: #{@root.resource}"

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
transcriber-0.0.26 examples/properties/with_two_key_converters.rb
transcriber-0.0.25 examples/properties/with_two_key_converters.rb
transcriber-0.0.24 examples/properties/with_two_key_converters.rb
transcriber-0.0.23 examples/properties/with_two_key_converters.rb
transcriber-0.0.22 examples/properties/with_two_key_converters.rb
transcriber-0.0.21 examples/properties/with_two_key_converters.rb
transcriber-0.0.20 examples/properties/with_two_key_converters.rb
transcriber-0.0.19 examples/properties/with_two_key_converters.rb
transcriber-0.0.18 examples/properties/with_two_key_converters.rb
transcriber-0.0.17 examples/properties/with_two_key_converters.rb
transcriber-0.0.16 examples/properties/with_two_key_converters.rb
transcriber-0.0.15 examples/properties/with_two_key_converters.rb
transcriber-0.0.14 examples/properties/with_two_key_converters.rb
transcriber-0.0.13 examples/properties/with_two_key_converters.rb
transcriber-0.0.12 examples/properties/with_two_key_converters.rb
transcriber-0.0.11 examples/properties/with_two_key_converters.rb
transcriber-0.0.10 examples/properties/with_two_key_converters.rb
transcriber-0.0.9 examples/properties/with_two_key_converters.rb
transcriber-0.0.8 examples/properties/with_two_key_converters.rb
transcriber-0.0.7 examples/properties/with_two_key_converters.rb