Module: Scorpio::ResourceBase::Container::Array

Includes:
Enumerable, JSI::Util::Arraylike
Defined in:
lib/scorpio/resource_base.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



581
582
583
# File 'lib/scorpio/resource_base.rb', line 581

def as_json(options = {})
  each_index.map { |i| JSI::Util.as_json(self[i], **options) }
end

#each(**kw, &block) ⇒ Object



571
572
573
574
575
# File 'lib/scorpio/resource_base.rb', line 571

def each(**kw, &block)
  return(to_enum(__method__, **kw) { contained_object.size }) unless block
  contained_object.each_index { |i| yield(self[i, **kw]) }
  self
end

#to_ary(**kw) ⇒ Object



577
578
579
# File 'lib/scorpio/resource_base.rb', line 577

def to_ary(**kw)
  to_a(**kw)
end