summaryrefslogtreecommitdiff
path: root/lib/ostruct.rb
AgeCommit message (Collapse)Author
2016-04-09* lib/ostruct.rb: [DOC] fix position of nodoc directive.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-03ostruct.rb: make internal methods privatenobu
* lib/ostruct.rb (modifiable?, new_ostruct_member!, table!): rename methods for internal use with suffixes and make private, [ruby-core:71069] [Bug #11587] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-01* lib/ostruct.rb: Fix case of frozen object with initializer.marcandre
Bug revealed by RubySpec [ruby-core:72639] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-31ostruct.rb: deferred accessorsnobu
* lib/ostruct.rb (freeze): define deferred accessors before freezing to get rid of an error when just reading frozen OpenStruct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-31* lib/ostruct.rb: Fix new_ostruct_member to correctly avoid redefinitionmarcandre
[#11901] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29ostruct.rb: respond_to?nobu
* lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12* lib/ostruct.rb: Have OpenStruct#dig raise if argument is not a symbolmarcandre
nor a string. See [#11762] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17OpenStruct#dignobu
* lib/ostruct.rb (dig): Implement OpenStruct#dig [Feature #11688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-14* lib/ostruct.rb: Finish defining OpenStruct attributes lazily.eregon
Patch by @sferik in [GH-1037]: https://github.com/ruby/ruby/pull/1037 This commit is an addendum to https://github.com/ruby/ruby/pull/1033. It: 1. lazily defines attribute accessors for copied and marshaled objects, 2. returns nil when an attribute reader is not defined, and 3. defines respond_to_missing? to maintain the same respond_to? behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-26ostruct.rb: fix NameErrornobu
* lib/ostruct.rb (delete_field): do not raise NameError for existing keys. [Fix GH-1033] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-26* lib/ostruct.rb: Move method definitions for getter/setter to be lazyzzak
Patch by @sferik in [GH-1033]: https://github.com/ruby/ruby/pull/1033 Instead of defining two methods -- a reader and writer -- for each OpenStruct attribute when it is initialized, define them lazily, the first time either one is called. This adheres to the principle of "pay for use": methods that are never accessed are never defined. This optimization makes initialization an order of magnitude faster for objects with 100 attributes. In the worst-case scenario, where every attribute is accessed, performance is no worse than it is today. Benchmark --------- require 'benchmark/ips' require 'ostruct' N = 100 ATTRS = (:aa..:zz).take(N) HASH = Hash[ATTRS.map { |x| [x, x] }] def ostruct OpenStruct.new(HASH) end Benchmark.ips do |x| x.report('ostruct') { ostruct } end ------------------------------------------------- before 2.279k (± 8.8%) i/s - 11.395k after 24.702k (±12.8%) i/s - 122.600k ------------------------------------------------- git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14ostruct.rb: match Symbol itselfnobu
* lib/ostruct.rb (method_missing): get rid of creating temporary string object for method name, match Symbol itself. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08Revert GH-808nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-05ostruct.rb: tablenobu
* lib/ostruct.rb (OpenStruct#table): revert for JSON. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-05ostruct.rb: append suffixes to protected methodsnobu
* lib/ostruct.rb (modifiable?, new_ostruct_member!, table!): append suffixes to protected methods so that they will not clash with assigned members. [Fix GH-806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* lib/ostruct.rb: raise NoMethodError with a #name and #args.marcandre
Patch by Kenichi Kamiya. [Fixes GH-383] * test/ostruct/test_ostruct.rb: Added tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* lib/ostruct.rb (Struct#each_pair): Return an enumerator with sizemarcandre
Patch by Kenichi Kamiya. [Fixes GH-383] * test/ostruct/test_ostruct.rb: Added tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* lib/ostruct.rb (OpenStruct#delete): Use the converted argument.marcandre
Patch by Kenichi Kamiya. [Fixes GH-383] * test/ostruct/test_ostruct.rb: Added tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23* lib/ostruct.rb: Raise RuntimeError when modifying frozen instancesmarcandre
instead of TypeError. Patch by Kenichi Kamiya. [Fixes GH-383] * test/ostruct/test_ostruct.rb: Added tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27* lib/ostruct.rb: Typo in OpenStruct overview [Github Fixes #251]zzak
Patch by Chun-wei Kuo git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Add [] and []=, base on a patch by Thomas Sawyermarcandre
[ruby-core:42779] [Feature #6056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Also accept {Open}Struct as argument to newmarcandre
[ruby-core:47476] [Feature #7007] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Simplify codemarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Add OpenStruct#eql? and OpenStruct#hashmarcandre
[ruby-core:42651] [Bug #6029] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb (each_pair): Add #each_pair [#1400]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Protect new_ostruct_member [ruby-core:42779] [#6056]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28* lib/ostruct.rb: Remove rdoc details on marshal_{load|dump} and fix rdocmarcandre
[ruby-core:42557] [ruby-core:42780] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.nobu
[Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18Revert r35339-35343 because of no tests.naruse
* hash.c: Alias ENV.to_h to ENV.to_hash [ref #6276] * lib/ostruct.rb: Add OpenStruct#to_h [Feature #6276] * struct.c: Add Struct#to_h [Feature #6276] * object.c: Add NilClass#to_h [Feature #6276] * hash.c: Add Hash#to_h [Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-16* lib/ostruct.rb: Add OpenStruct#to_h [Feature #6276]marcandre
[ref #1400] [rubyspec:9e0250b2fc6f] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22* lib/ostruct.rb (delete_field): Bug fix so previous value is returned.marcandre
Patch by Nick Recobra [Bug #6063] * test/ostruct/test_ostruct.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15* lib/ostruct.rb: Create getters and setters after dup.marcandre
[Bug #6028] [rubyspecs:0380bcc] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15* lib/ostruct.rb: Simplify and fix rdoc.marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-26* ext/pathname/lib/pathname.rb: Fix typos and grammar mistakes. Patchdrbrain
by Luke Gruber. [#5203] * ext/pty/lib/expect.rb: ditto * lib/mathn.rb: ditto * lib/net/http.rb: ditto * lib/open-uri.rb: ditto * lib/ostruct.rb: ditto * lib/tempfile.rb: ditto * lib/thread.rb: ditto * lib/weakref.rb: ditto * sample/webrick/httpproxy.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27* lib/ostruct.rb (method_missing): Handle [] and []= correctly.marcandre
Based on a patch by Caius Durling, bug #4179 [ruby-core:33792] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-22 * lib/ostruct.rb: Improve documentation. Patch by Franklin Webber.drbrain
[Ruby 1.9 - Bug #4761] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-03* lib/ostruct.rb (OpenStruct#delete_field): also undefinenobu
accessor methods. [ruby-core:33010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06* {ext,lib,test}/**/*.rb: removed trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-27* lib/ostruct.rb (modifiable): check if really frozen.nobu
[ruby-core:22559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-15* lib/ostruct.rb (OpenStruct#new_ostruct_member): checks if frozen.nobu
[ruby-talk:328195], [ruby-core:22142] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-13* lib/ostruct.rb (OpenStruct#inspect): fixed the recursion check.yugui
Patch by Kornelius Kalnbach. [ruby-core:20992]. * test/ostruct/test_ostruct.rb: test for inspect. Patch by Kornelius Kalnbach. [ruby-core:20992]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12* lib/ostruct.rb (new_ostruct_member): Object#send no longer callnobu
private methods. [ruby-dev:27044] * test/rss/test_dublincore.rb, test/rss/test_trackback.rb, test/ruby/test_eval.rb, test/socket/test_socket.rb: ditto. * test/ruby/test_lambda (test_call_with_block): lambda makes new scope for formal block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-05* lib/ostruct.rb: a patch from Florian Gross <florgro@gmail.com>matz
merged to allow recursive inspect (and to_s) for OpenStruct. [ruby-core:05532] * lib/observer.rb: a patch from nornagon <nornagon@gmail.com> merged to allow arbitrary names for update methods. [ruby-core:05416] * eval.c (rb_f_fcall): new method to avoid inefficiency of obj.instance_eval{send(...)} tricks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-03* eval.c (proc_invoke): prepare to pass a block from "call" methodmatz
to a Proc generated by Method#to_proc. [ruby-dev:25031] * eval.c (rb_yield_0): actually passes a block given to "call". * object.c (convert_type): use rb_respond_to() again. this fix is based on [ruby-dev:25021] * eval.c (rb_respond_to): funcall respond_to? if it's redefined. [ruby-dev:25021] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-02* io.c (rb_file_initialize): [ruby-dev:25032]matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-29* io.c (rb_io_sysread): use temporary lock. [ruby-dev:24992]matz
* lib/ostruct.rb (OpenStruct::method_missing): check method duplication for -d. * lib/ostruct.rb (OpenStruct::initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-27* node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.matz
[ruby-talk:117841] * ruby.h (FL_ABLE): nodes are not subject for flag operations. * io.c (ARGF_FORWARD): should have specified argv explicitly, since we no longer have frame->argv saved. [ruby-dev:24602] * string.c (RESIZE_CAPA): check string attribute before modifying capacity member of string structure. [ruby-dev:24594] * ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain performance. [ruby-talk:117701] * sprintf.c (rb_f_sprintf): raise ArgumentError for extra arguments, unless (digit)$ style used. * io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in interpreter termination. [ruby-dev:24579] * eval.c (frame_free): Guy Decoux solved the leak problem. Thanks. [ruby-core:03549] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-03-29* exception message clean-up by Ian Macdonald <ian@caliban.org>.matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-02-20* lib/ostruct.rb (OpenStruct#initialize_copy): should not sharenobu
members. [ruby-dev:22966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e