Module: Familia::DataType::Settings

Defined in:
lib/familia/data_type/settings.rb

Overview

Settings - Instance-level configuration and introspection methods

This module provides instance methods for accessing and managing DataType object configuration, parent relationships, and serialization.

Key features:

  • Parent object relationship management
  • URI and database configuration
  • Serialization method delegation
  • Type introspection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keystringObject (readonly)

Returns the value of attribute keystring.



19
20
21
# File 'lib/familia/data_type/settings.rb', line 19

def keystring
  @keystring
end

#logical_databaseObject (readonly)

Returns the value of attribute logical_database.



19
20
21
# File 'lib/familia/data_type/settings.rb', line 19

def logical_database
  @logical_database
end

#optsObject (readonly)

Returns the value of attribute opts.



19
20
21
# File 'lib/familia/data_type/settings.rb', line 19

def opts
  @opts
end

#uriObject

Returns the value of attribute uri.



20
21
22
# File 'lib/familia/data_type/settings.rb', line 20

def uri
  @uri
end

Instance Method Details

#class?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/familia/data_type/settings.rb', line 24

def class?
  !@opts[:class].to_s.empty? && @opts[:class].is_a?(Familia)
end

#parentObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/familia/data_type/settings.rb', line 40

def parent
  # Return cached ParentDefinition if available
  return @parent if @parent

  # Return class-level parent if no instance parent
  return self.class.parent unless @parent_ref

  # Create ParentDefinition dynamically from stored reference.
  # This ensures we get the current identifier value (available after initialization)
  # rather than a stale nil value from initialization time. Cannot cache due to frozen object.
  Horreum::ParentDefinition.from_parent(@parent_ref)
end

#parent=(value) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/familia/data_type/settings.rb', line 53

def parent=(value)
  case value
  when Horreum::ParentDefinition
    @parent = value
  when nil
    @parent = nil
    @parent_ref = nil
  else
    # Store parent instance reference for lazy ParentDefinition creation.
    # During initialization, the parent's identifier may not be available yet,
    # so we defer ParentDefinition creation until first access for memory efficiency.
    # Note: @parent_ref is not cleared after use because DataType objects are frozen.
    @parent_ref = value
    @parent = nil  # Will be created dynamically in parent method
  end
end

#parent?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/familia/data_type/settings.rb', line 36

def parent?
  parent_class? || parent_instance?
end

#parent_class?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/familia/data_type/settings.rb', line 32

def parent_class?
  parent.is_a?(Class) && parent.ancestors.include?(Familia::Horreum)
end

#parent_instance?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/familia/data_type/settings.rb', line 28

def parent_instance?
  parent&.is_a?(Horreum::ParentDefinition)
end

#urlObject

Returns the value of attribute uri.



22
23
24
# File 'lib/familia/data_type/settings.rb', line 22

def uri
  @uri
end