Class: Moku6::Rules::VisibilityRule

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/moku6/rules/visibility_rule.rb

Instance Method Summary collapse

Methods inherited from BaseRule

#initialize

Constructor Details

This class inherits a constructor from Moku6::Rules::BaseRule

Instance Method Details

#check(event) ⇒ Object

: (Event event) -> Array



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/moku6/rules/visibility_rule.rb', line 8

def check(event)
  visibility = event.visibility
  unless visibility.is_a?(Hash) &&
      visibility.key?("customer_visible") && visibility.key?("internal_only")
    return [offense(event, :error,
      "customer_visible / internal_only must be set explicitly.",
      rule: "visibility_explicit")]
  end

  if visibility["customer_visible"] && visibility["internal_only"]
    return [offense(event, :warning,
      "customer_visible and internal_only are contradictory.",
      rule: "visibility_consistency")]
  end

  []
end