Sha256: 81d4d4b4d82f0d39a1552f0829948d220175a82751c98e95cf971a9f16e8441c

Contents?: true

Size: 418 Bytes

Versions: 11

Compression:

Stored size: 418 Bytes

Contents

# frozen_string_literal: false

require 'ostruct' unless defined?(OpenStruct)

class OpenStruct

  def attributes
    @table
  end

  def replace(args)
    args.each { |key, val| self[key] = val }
  end

  def to_hash(table: true)
    return attributes unless table

    { table: attributes }
  end

  def to_json(table: true)
    to_hash(table: table).to_json
  end

  alias as_json to_json
  alias to_h to_hash

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lite-ruby-2.3.0 lib/lite/ruby/open_struct.rb
lite-ruby-2.2.0 lib/lite/ruby/open_struct.rb
lite-ruby-2.1.0 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.7 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.6 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.5 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.4 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.3 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.2 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.1 lib/lite/ruby/open_struct.rb
lite-ruby-2.0.0 lib/lite/ruby/open_struct.rb