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.
45 46 47 48 |
# File 'lib/archspec/rules/protocol_rules.rb', line 45 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.
43 44 45 |
# File 'lib/archspec/rules/protocol_rules.rb', line 43 def method_name @method_name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
43 44 45 |
# File 'lib/archspec/rules/protocol_rules.rb', line 43 def source @source end |
Instance Method Details
#evaluate(graph) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/archspec/rules/protocol_rules.rb', line 58 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
54 55 56 |
# File 'lib/archspec/rules/protocol_rules.rb', line 54 def id 'protocol.must_implement' end |
#merge_key ⇒ Object
50 51 52 |
# File 'lib/archspec/rules/protocol_rules.rb', line 50 def merge_key [self.class, source, method_name] end |