mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/ostruct] [DOC] Fix code markups [ci skip]
Backquotes are not special characters in RDoc. https://github.com/ruby/ostruct/commit/a901df26b9
This commit is contained in:
parent
0e5e2e35f8
commit
ca7de49aa5
1 changed files with 6 additions and 6 deletions
|
@ -93,16 +93,16 @@
|
||||||
# o.methods = [:foo, :bar]
|
# o.methods = [:foo, :bar]
|
||||||
# o.methods # => [:foo, :bar]
|
# o.methods # => [:foo, :bar]
|
||||||
#
|
#
|
||||||
# To help remedy clashes, OpenStruct uses only protected/private methods ending with `!`
|
# To help remedy clashes, OpenStruct uses only protected/private methods ending with <code>!</code>
|
||||||
# and defines aliases for builtin public methods by adding a `!`:
|
# and defines aliases for builtin public methods by adding a <code>!</code>:
|
||||||
#
|
#
|
||||||
# o = OpenStruct.new(make: 'Bentley', class: :luxury)
|
# o = OpenStruct.new(make: 'Bentley', class: :luxury)
|
||||||
# o.class # => :luxury
|
# o.class # => :luxury
|
||||||
# o.class! # => OpenStruct
|
# o.class! # => OpenStruct
|
||||||
#
|
#
|
||||||
# It is recommended (but not enforced) to not use fields ending in `!`;
|
# It is recommended (but not enforced) to not use fields ending in <code>!</code>;
|
||||||
# Note that a subclass' methods may not be overwritten, nor can OpenStruct's own methods
|
# Note that a subclass' methods may not be overwritten, nor can OpenStruct's own methods
|
||||||
# ending with `!`.
|
# ending with <code>!</code>.
|
||||||
#
|
#
|
||||||
# For all these reasons, consider not using OpenStruct at all.
|
# For all these reasons, consider not using OpenStruct at all.
|
||||||
#
|
#
|
||||||
|
@ -279,7 +279,7 @@ class OpenStruct
|
||||||
# :call-seq:
|
# :call-seq:
|
||||||
# ostruct[name] -> object
|
# ostruct[name] -> object
|
||||||
#
|
#
|
||||||
# Returns the value of an attribute, or `nil` if there is no such attribute.
|
# Returns the value of an attribute, or +nil+ if there is no such attribute.
|
||||||
#
|
#
|
||||||
# require "ostruct"
|
# require "ostruct"
|
||||||
# person = OpenStruct.new("name" => "John Smith", "age" => 70)
|
# person = OpenStruct.new("name" => "John Smith", "age" => 70)
|
||||||
|
@ -452,7 +452,7 @@ class OpenStruct
|
||||||
update_to_values!(h)
|
update_to_values!(h)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make all public methods (builtin or our own) accessible with `!`:
|
# Make all public methods (builtin or our own) accessible with <code>!</code>:
|
||||||
instance_methods.each do |method|
|
instance_methods.each do |method|
|
||||||
new_name = "#{method}!"
|
new_name = "#{method}!"
|
||||||
alias_method new_name, method
|
alias_method new_name, method
|
||||||
|
|
Loading…
Add table
Reference in a new issue