class Zn::Dataset
Holds repo, associators and performs aggregate operations
Attributes
associators[R]
repo[R]
Public Class Methods
new(repo)
click to toggle source
# File lib/zn/dataset.rb, line 12 def initialize(repo) @repo = repo @associators = {} end
Public Instance Methods
add_associator(name, associator)
click to toggle source
# File lib/zn/dataset.rb, line 17 def add_associator(name, associator) @associators[name] = associator end
associate(entities) { |entity, associations(entity)| ... }
click to toggle source
# File lib/zn/dataset.rb, line 37 def associate(entities) return enum_for(:associate, entities) unless block_given? entities.each do |entity| yield entity, associations(entity) end end
associations(entity)
click to toggle source
# File lib/zn/dataset.rb, line 31 def associations(entity) associators.each_with_object({}) do |(name, associator), hash| hash[name] = associator.associate(entity) end end
keys()
click to toggle source
# File lib/zn/dataset.rb, line 21 def keys keys = Set.new repo.all.each do |entity| keys = keys.merge entity.keys end keys.to_a end