Module: JSI::Base::Enumerable
Instance Method Summary collapse
-
#as_json(*opt) ⇒ Object
a jsonifiable representation of the node content.
-
#to_a(**kw) ⇒ Array
(also: #entries)
an Array containing each item in this JSI.
Instance Method Details
#as_json(*opt) ⇒ Object
a jsonifiable representation of the node content
26 27 28 29 30 31 |
# File 'lib/jsi/base/node.rb', line 26 def as_json(*opt) # include Enumerable (above) means, if ActiveSupport is loaded, its undesirable #as_json is included # https://github.com/rails/rails/blob/v7.0.0/activesupport/lib/active_support/core_ext/object/json.rb#L139-L143 # although Base#as_json does clobber activesupport's, I want as_json defined correctly on the module too. Typelike.as_json(jsi_node_content, *opt) end |
#to_a(**kw) ⇒ Array Also known as: entries
an Array containing each item in this JSI.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jsi/base/node.rb', line 11 def to_a(**kw) # TODO remove eventually (keyword argument compatibility) # discard when all supported ruby versions Enumerable#to_a delegate keywords to #each (3.0.1 breaks; 2.7.x warns) # https://bugs.ruby-lang.org/issues/18289 ary = [] each(**kw) do |e| ary << e end ary end |