Sha256: 7d79beeaa6d79c148c95abe62685facfa0ac51a34a916ccaced6679df9dc7048
Contents?: true
Size: 724 Bytes
Versions: 9
Compression:
Stored size: 724 Bytes
Contents
module Praxis class CollectionView attr_reader :name, :schema, :using def initialize(name, schema, using) @name = name @schema = schema @using = using end def dump(collection, context: Attributor::DEFAULT_ROOT_CONTEXT,**opts) collection.collect.with_index do |object, i| subcontext = context + ["at(#{i})"] using.dump(object, context: subcontext, **opts) end end def example(context=Attributor::DEFAULT_ROOT_CONTEXT) collection = self.schema.example(context) opts = {} opts[:context] = context if context self.dump(collection, opts) end def describe using.describe.merge(type: :collection) end end end
Version data entries
9 entries across 9 versions & 1 rubygems