module Realm

Public Class Methods

Struct(attributes = Dry::Core::Constants::EMPTY_HASH, &block) click to toggle source

port the construction method from Dry::Struct as it's not inherited

# File lib/realm.rb, line 22
def Struct(attributes = Dry::Core::Constants::EMPTY_HASH, &block) # rubocop:disable Naming/MethodName
  Class.new(Struct) do
    attributes.each { |a, type| attribute a, type }
    module_eval(&block) if block
  end
end
bind(root_module, **options) click to toggle source

Bind realm in service/engine

# File lib/realm.rb, line 15
def bind(root_module, **options)
  setup(root_module, **options).tap do |builder|
    root_module.define_singleton_method(:realm) { builder.runtime }
  end
end
setup(root_module, **options) click to toggle source

Setup realm in test/console

# File lib/realm.rb, line 9
def setup(root_module, **options)
  config = Realm::Config.new(root_module: root_module, **options)
  Realm::Builder.setup(config)
end