Class: Ast::Merge::Ruleset::RuntimeDeclaration

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/ruleset/runtime_declaration.rb

Overview

Merge-facing view of ruleset declarations after translation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(read_strategy:, attachment_strategy:, comment_style: nil, render_family: nil, capabilities: {}, logical_owners: {}, support_style: nil, metadata: {}) ⇒ RuntimeDeclaration

Returns a new instance of RuntimeDeclaration.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 18

def initialize(
  read_strategy:,
  attachment_strategy:,
  comment_style: nil,
  render_family: nil,
  capabilities: {},
  logical_owners: {},
  support_style: nil,
  metadata: {}
)
  @read_strategy = read_strategy&.to_sym
  @attachment_strategy = attachment_strategy&.to_sym
  @comment_style = comment_style&.to_sym
  @render_family = render_family&.to_sym
  @capabilities = capabilities.dup.freeze
  @logical_owners = logical_owners.dup.freeze
  @logical_owner_policies = @logical_owners.map do |kind, action|
    LogicalOwnerPolicy.new(kind: kind, action: action)
  end.freeze
  @support_style = support_style
  @metadata = .dup.freeze
end

Instance Attribute Details

#attachment_strategyObject (readonly)

Returns the value of attribute attachment_strategy.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def attachment_strategy
  @attachment_strategy
end

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def capabilities
  @capabilities
end

#comment_styleObject (readonly)

Returns the value of attribute comment_style.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def comment_style
  @comment_style
end

#logical_owner_policiesObject (readonly)

Returns the value of attribute logical_owner_policies.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def logical_owner_policies
  @logical_owner_policies
end

#logical_ownersObject (readonly)

Returns the value of attribute logical_owners.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def logical_owners
  @logical_owners
end

#metadataObject (readonly)

Returns the value of attribute metadata.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def 
  @metadata
end

#read_strategyObject (readonly)

Returns the value of attribute read_strategy.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def read_strategy
  @read_strategy
end

#render_familyObject (readonly)

Returns the value of attribute render_family.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def render_family
  @render_family
end

#support_styleObject (readonly)

Returns the value of attribute support_style.



8
9
10
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 8

def support_style
  @support_style
end

Instance Method Details

#comment_free?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 41

def comment_free?
  comment_style.nil? && support_style.nil?
end

#logical_owner?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 45

def logical_owner?
  logical_owners.any?
end

#to_hObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ast/merge/ruleset/runtime_declaration.rb', line 49

def to_h
  {
    read_strategy: read_strategy,
    attachment_strategy: attachment_strategy,
    comment_style: comment_style,
    render_family: render_family,
    capabilities: capabilities,
    logical_owners: logical_owners,
    logical_owner_policies: logical_owner_policies.map(&:to_h),
    support_style: support_style&.to_h,
    metadata: ,
    comment_free: comment_free?,
    logical_owner: logical_owner?
  }.compact
end