Class: Julewire::Core::Records::PublicProjection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/julewire/core/records/public_projection.rb

Constant Summary collapse

INTERNAL_KEYS =
Fields::Bags.hidden_output_sections
INTERNAL_EXECUTION_KEYS =
%i[
  ancestors
  ancestors_truncated
  depth
  parent
  root
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ PublicProjection

Returns a new instance of PublicProjection.



26
27
28
29
# File 'lib/julewire/core/records/public_projection.rb', line 26

def initialize(record)
  Record.validate_normalized!(record)
  @record = record
end

Class Method Details

.public_execution(value) ⇒ Object



19
20
21
22
23
# File 'lib/julewire/core/records/public_projection.rb', line 19

def public_execution(value)
  return value unless INTERNAL_EXECUTION_KEYS.any? { value.key?(it) }

  value.except(*INTERNAL_EXECUTION_KEYS)
end

Instance Method Details

#eachObject



31
32
33
34
35
36
37
38
39
# File 'lib/julewire/core/records/public_projection.rb', line 31

def each
  return enum_for(:each) unless block_given?

  @record.each do |key, value|
    next if INTERNAL_KEYS.include?(key)

    yield key, output_value(key, value)
  end
end