Sha256: 9c8a0d28aedc525170a62aa1f8d2301321c27e494618f5000e7d1b686b7a32b0

Contents?: true

Size: 539 Bytes

Versions: 6

Compression:

Stored size: 539 Bytes

Contents

module RakutenWebService
  module Travel
    class OpenStruct
      using RakutenWebService::StringSupport

      def initialize(hash)
        @table = {}
        hash.each do |(key, val)|
          val = self.class.new(val) if val.is_a?(Hash)
          val = val.map { |v| self.class.new(v) } if val.is_a?(Array)
          name = key.to_sym
          @table[name] = val
          define_singleton_method(name) { @table[name] }
          define_singleton_method(name.to_s.to_snake) { @table[name] }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rakuten_web_service-1.13.2 lib/rakuten_web_service/travel/open_struct.rb
rakuten_web_service-1.13.1 lib/rakuten_web_service/travel/open_struct.rb
rakuten_web_service-1.13.0 lib/rakuten_web_service/travel/open_struct.rb
rakuten_web_service-1.12.0 lib/rakuten_web_service/travel/open_struct.rb
rakuten_web_service-1.11.0 lib/rakuten_web_service/travel/open_struct.rb
rakuten_web_service-1.10.0 lib/rakuten_web_service/travel/open_struct.rb