Sampat Badhe
ae2dbdf11e
[DOC] Fix broken link Data#deconstruct_keys
2023-03-08 12:26:26 +09:00
John Bampton
c43fbe4ebd
Fix spelling ( #7405 )
2023-02-28 10:05:30 -08:00
BurdetteLamar
3b239d2480
Remove (newly unneeded) remarks about aliases
2023-02-19 14:26:34 -08:00
Nobuyoshi Nakada
45f0e3a673
[Bug #19259 ] `Data#with` should call `initialize` method
2023-02-14 12:02:07 +09:00
Jean Boussier
cc9d96b259
Avoid using OBJ_WB_UNPROTECT
...
Not that it makes a big difference here, but it's
just unecessary.
2023-02-03 23:31:08 +01:00
Kouhei Yanagita
3fefe660f8
[DOC] Fix call-seq of Struct.new ( #7246 )
2023-02-03 14:26:39 -08:00
Kouhei Yanagita
cada537040
[DOC] Fix call-seq for Data.define
2022-12-28 18:43:05 +02:00
zverok
b3d57fdd64
Docs: Update Struct docs about keyword initialization
2022-12-23 18:09:49 +02:00
Ufuk Kayserilioglu
99cee85775
Add copy with changes functionality for Data objects ( #6766 )
...
Implements [Feature #19000 ]
This commit adds copy with changes functionality for `Data` objects
using a new method `Data#with`.
Since Data objects are immutable, the only way to change them is by
creating a copy. This PR adds a `with` method for `Data` class instances
that optionally takes keyword arguments.
If the `with` method is called with no arguments, the behaviour is the
same as the `Kernel#dup` method, i.e. a new shallow copy is created
with no field values changed.
However, if keyword arguments are supplied to the `with` method, then
the copy is created with the specified field values changed. For
example:
```ruby
Point = Data.define(:x, :y)
point = Point.new(x: 1, y: 2)
point.with(x: 3) # => #<data Point x: 3, y: 2>
```
Passing positional arguments to `with` or passing keyword arguments to
it that do not correspond to any of the members of the Data class will
raise an `ArgumentError`.
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2022-12-21 16:27:38 -08:00
Nobuyoshi Nakada
5872fd6f6c
[Feature #19163 ] Marshal-loaded Data object also should be frozen
2022-12-02 00:56:52 +09:00
Nobuyoshi Nakada
a14a1a5626
[Feature #19163 ] Data object should be frozen
2022-12-02 00:56:52 +09:00
Alan Wu
5752d11f1f
Use RTEST and add test for GH-6832
...
Technically we shouldn't see Qfalse now, but RTEST also compiles down to
just one branch anyways. Pretty contrived issue, but easy to fix.
2022-11-30 16:27:39 -05:00
Zack Deveau
4b9d10b833
struct.c (struct_ivar_get): add conditional for potential Qnil returned by rb_class_superclass
...
struct_ivar_get recently started using rb_class_superclass to
resolve super instead of RCLASS_SUPER. This change made
Qnil a possible case we need to return from within the
struct_ivar_get for loop.
2022-11-30 16:27:39 -05:00
S-H-GAMELINKS
1f4f6c9832
Using UNDEF_P macro
2022-11-16 18:58:33 +09:00
Yuri Smirnov
13e87e5049
fix Data docs ( #6497 )
2022-10-06 10:13:17 -07:00
Nobuyoshi Nakada
cbd82f5250
Cannot `define` from defined `Data` class again
2022-10-03 23:28:01 +09:00
Nobuyoshi Nakada
56f2fd3bc9
Use the dedicated function to check arity
2022-10-01 16:24:36 +09:00
Nobuyoshi Nakada
15d3b7fe6d
Fix an out of bound access
2022-10-01 16:20:22 +09:00
Nobuyoshi Nakada
c767618d4c
Do not define the method only for RDoc
...
`Data.members` fails an assertion.
2022-10-01 15:36:01 +09:00
Victor Shepelev
ad651925e3
Add Data class implementation: Simple immutable value object
2022-09-30 18:23:19 +09:00
Nobuyoshi Nakada
cfe10e482e
[DOC] Update `Struct#new` behavior with `keyword_init: true`
2022-09-09 18:58:07 +09:00
Peter Zhu
efb91ff19b
Rename rb_ary_tmp_new to rb_ary_hidden_new
...
rb_ary_tmp_new suggests that the array is temporary in some way, but
that's not true, it just creates an array that's hidden and not on the
transient heap. This commit renames it to rb_ary_hidden_new.
2022-07-26 09:12:09 -04:00
Takashi Kokubun
5b21e94beb
Expand tabs [ci skip]
...
[Misc #18891 ]
2022-07-21 09:42:04 -07:00
John Hawthorn
adc709adb8
Don't attempt to read ivars on T_ICLASS in struct ( #5664 )
2022-05-26 11:54:15 -07:00
Peter Zhu
54b53e2c8f
[ci skip] Fix docs
2022-04-13 10:43:23 -04:00
Burdette Lamar
ffcdbedbfb
Repaired What's Here sections for Range, String, Symbol, Struct ( #5735 )
...
Repaired What's Here sections for Range, String, Symbol, Struct.
2022-03-30 13:46:24 -05:00
Nobuyoshi Nakada
e660b934b9
A positional Hash is not keyword arguments [Bug #18632 ]
2022-03-17 20:53:41 +09:00
Nobuyoshi Nakada
50c972a1ae
[DOC] Simplify operator method references
2022-02-12 12:38:36 +09:00
Peter Zhu
a32e5e1b97
[DOC] Use RDoc link style for links in the same class/module
...
I used this regex:
(?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+)
And performed a global find & replace for this:
rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Peter Zhu
f9a2802bc5
[DOC] Use RDoc link style for links to other classes/modules
...
I used this regex:
([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+)
And performed a global find & replace for this:
rdoc-ref:$1@$2
2022-02-07 09:52:06 -05:00
Burdette Lamar
a07fa198a6
Improve links to labels in string.c and struct.c ( #5531 )
2022-02-06 09:44:40 -06:00
Nobuyoshi Nakada
c956f979e5
Initialize Struct by calling with keyword arguments
2021-12-26 23:28:54 +09:00
Kazuhiro NISHIYAMA
04f07713d1
Fix typos [ci skip]
2021-12-25 10:33:49 +09:00
zverok
fed1629ada
Fix StructClass:: class method docs
2021-12-24 10:29:31 +09:00
Nobuyoshi Nakada
c5ec05d047
`struct_pos_num` is no longer used
2021-11-20 21:32:57 +09:00
Koichi Sasada
82ea287018
optimize `Struct` getter/setter
...
Introduce new optimized method type
`OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information.
2021-11-19 08:32:39 +09:00
Nobuyoshi Nakada
4fb71575e2
[DOC] Fix code markup [ci skip]
...
Code markup in RDoc must not be concatenated with anothr word.
2021-10-25 01:04:51 +09:00
S.H
dc9112cf10
Using NIL_P macro instead of `== Qnil`
2021-10-03 22:34:45 +09:00
Burdette Lamar
2cf1014362
Enhanced RDoc for Struct ( #4895 )
...
Revises introductory material.
Adds section "What's Here".
Adds previously missing documentation for method #deconstruct_keys.
2021-09-27 18:17:47 -05:00
Burdette Lamar
39a6bf5513
Enhanced RDoc for Struct ( #4891 )
...
Treats:
#values_at
#select
#==
#hash
#eql?
#size
#dig
2021-09-24 18:41:02 -05:00
Burdette Lamar
bbdfce96a2
Enhanced RDoc for Struct ( #4890 )
...
Treated:
#each
#each_pair
#inspect
#to_a
#to_h
#[]
#[]=
2021-09-24 10:35:19 -05:00
Burdette Lamar
b38d2bf118
Enhance RDoc for Struct ( #4885 )
...
Treats #members and ::new.
2021-09-23 17:21:40 -05:00
Nobuyoshi Nakada
a27c274f04
[DOC] Fix broken links [ci skip]
...
* As the "doc/" prefix is specified by the `--page-dir` option,
remove from the rdoc references.
* Refer to the original .rdoc instead of the converted .html.
2021-09-15 14:16:14 +09:00
S-H-GAMELINKS
56065f0686
Using SYMBOL_P macro
2021-09-11 08:48:56 +09:00
Nobuyoshi Nakada
3e7a7fb28a
Make Struct#keyword_init? return nil by default [Feature #18008 ]
2021-07-15 22:24:02 +09:00
Nobuyoshi Nakada
33bea3bdff
Regularize keyword_init values not to hold the argument object
2021-07-15 21:32:04 +09:00
hkdnet
1a63754416
struct.c: Add keyword_init? singleton method for StructClass ( #4609 )
...
Fixes [Feature #18008 ]
2021-07-15 18:14:27 +09:00
Takashi Kokubun
8d099aa040
Warn Struct#initialize with only keyword args ( #4070 )
...
* Warn Struct#initialize with only keyword args
A part of [Feature #16806 ]
* Do not warn if `keyword_init: false`
is explicitly specified
* Add a NEWS entry
* s/in/from/
* Make sure all fields are initialized
2021-01-17 01:35:54 -08:00
卜部昌平
99093e1600
RHASH_TBL: is now ext-only
...
It seems almost no internal codes use RHASH_TBL any longer. Why not
just eliminate it entirely, so that the macro can be purely ext-only.
2020-08-19 15:10:53 +09:00
Burdette Lamar
c84ccf1a07
Fix links to Dig Methods document ( #3421 )
...
* Fix links to Dig Methods document
* Fix links to Dig Methods document
2020-08-14 18:55:04 -05:00