lib/lite/ruby/open_struct.rb in lite-ruby-1.3.3 vs lib/lite/ruby/open_struct.rb in lite-ruby-2.0.0

- old
+ new

@@ -1,30 +1,28 @@ # frozen_string_literal: false -if Lite::Ruby.configuration.monkey_patches.include?('open_struct') - require 'ostruct' +require 'ostruct' unless defined?(OpenStruct) - class OpenStruct +class OpenStruct - def attributes - @table - end + def attributes + @table + end - def replace(args) - args.each { |key, val| self[key] = val } - end + def replace(args) + args.each { |key, val| self[key] = val } + end - def to_hash(table: true) - return attributes unless table + def to_hash(table: true) + return attributes unless table - { table: attributes } - end + { table: attributes } + end - def to_json(table: true) - to_hash(table: table).to_json - end + def to_json(table: true) + to_hash(table: table).to_json + end - alias as_json to_json - alias to_h to_hash + alias as_json to_json + alias to_h to_hash - end end