Class: ArchSpec::Rules::MustImplementRule
- Inherits:
-
Object
- Object
- ArchSpec::Rules::MustImplementRule
- Defined in:
- lib/archspec/rules/protocol_rules.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #evaluate(graph) ⇒ Object
- #id ⇒ Object
-
#initialize(source, method_name) ⇒ MustImplementRule
constructor
A new instance of MustImplementRule.
- #merge_key ⇒ Object
Constructor Details
#initialize(source, method_name) ⇒ MustImplementRule
Returns a new instance of MustImplementRule.
43 44 45 46 |
# File 'lib/archspec/rules/protocol_rules.rb', line 43 def initialize(source, method_name) @source = source.to_sym @method_name = method_name.to_sym end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
41 42 43 |
# File 'lib/archspec/rules/protocol_rules.rb', line 41 def method_name @method_name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
41 42 43 |
# File 'lib/archspec/rules/protocol_rules.rb', line 41 def source @source end |
Instance Method Details
#evaluate(graph) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/archspec/rules/protocol_rules.rb', line 56 def evaluate(graph) constants_for(graph).filter_map do |constant| next if constant.instance_methods.include?(method_name) Diagnostic.new( rule: id, message: "#{constant.name} must implement ##{method_name}", location: constant.location, evidence: "#{constant.name} methods: #{constant.instance_methods.to_a.sort.join(", ")}" ) end end |
#id ⇒ Object
52 53 54 |
# File 'lib/archspec/rules/protocol_rules.rb', line 52 def id "protocol.must_implement" end |
#merge_key ⇒ Object
48 49 50 |
# File 'lib/archspec/rules/protocol_rules.rb', line 48 def merge_key [self.class, source, method_name] end |