Class: Jazari::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/jazari.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jazari.rb', line 38

def initialize(*)
  super
  self.anchor_scopes ||= {}
  self.table_prefix  ||= "jazari_"
  # Per-table overrides. A prefix alone is not enough for a host adopting
  # tables it already has: existing names rarely follow one scheme, and
  # renaming live tables in the same deploy as a cut-over is exactly what
  # the adoption plan forbids. Any key omitted falls back to the prefix.
  self.table_names   ||= {}
  # Optional zero-argument provider for trusted system contexts. User and
  # agent callers should pass an explicit opaque actor_ref.
  self.actor_ref     = nil if actor_ref.nil?
end

Instance Attribute Details

#actor_refObject

Returns the value of attribute actor_ref

Returns:

  • (Object)

    the current value of actor_ref



36
37
38
# File 'lib/jazari.rb', line 36

def actor_ref
  @actor_ref
end

#anchor_scopesObject

Returns the value of attribute anchor_scopes

Returns:

  • (Object)

    the current value of anchor_scopes



36
37
38
# File 'lib/jazari.rb', line 36

def anchor_scopes
  @anchor_scopes
end

#on_subject_destroyedObject

Returns the value of attribute on_subject_destroyed

Returns:

  • (Object)

    the current value of on_subject_destroyed



36
37
38
# File 'lib/jazari.rb', line 36

def on_subject_destroyed
  @on_subject_destroyed
end

#table_namesObject

Returns the value of attribute table_names

Returns:

  • (Object)

    the current value of table_names



36
37
38
# File 'lib/jazari.rb', line 36

def table_names
  @table_names
end

#table_prefixObject

Returns the value of attribute table_prefix

Returns:

  • (Object)

    the current value of table_prefix



36
37
38
# File 'lib/jazari.rb', line 36

def table_prefix
  @table_prefix
end

Instance Method Details

#validate!Object

Fail at boot, not at first call.



53
54
55
56
57
58
59
60
61
62
# File 'lib/jazari.rb', line 53

def validate!
  anchor_scopes.each_key do |scope|
    raise ArgumentError, "anchor scope #{scope.inspect} must be a String" unless scope.is_a?(String)
  end
  if actor_ref && !actor_ref.is_a?(String) &&
      !(actor_ref.respond_to?(:call) && actor_ref.respond_to?(:arity) && actor_ref.arity.zero?)
    raise ArgumentError, "actor_ref must be a String or zero-argument callable"
  end
  true
end