Module: Abstractor::Methods::Models::AbstractorAbstraction::InstanceMethods
- Included in:
- AbstractorAbstraction
- Defined in:
- lib/abstractor/methods/models/abstractor_abstraction.rb
Instance Method Summary collapse
-
#detect_abstractor_indirect_source(abstractor_abstraction_source) ⇒ Abstractor::AbstractorIndirectSource?
Detects if the abstraction already has an Abstractor::AbstractorIndirectSource based on the Abstractor::AbstractorAbstractionSource passed via the abstractor_abstraction_source parameter.
- #detect_abstractor_suggestion(suggested_value, unknown, not_applicable) ⇒ Object
- #display_value ⇒ Object
- #matching_abstractor_suggestions ⇒ Object
- #review_matching_suggestions ⇒ Object
-
#unreviewed? ⇒ Boolean
Determines if the abstraction has been reviewed.
Instance Method Details
#detect_abstractor_indirect_source(abstractor_abstraction_source) ⇒ Abstractor::AbstractorIndirectSource?
Detects if the abstraction already has an Abstractor::AbstractorIndirectSource based on the Abstractor::AbstractorAbstractionSource passed via the abstractor_abstraction_source parameter. Retuns it if present. Otherwise nil.
87 88 89 90 91 92 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 87 def detect_abstractor_indirect_source(abstractor_abstraction_source) abstractor_indirect_source = nil abstractor_indirect_source = abstractor_indirect_sources(true).detect do |ais| ais.abstractor_abstraction_source == abstractor_abstraction_source end end |
#detect_abstractor_suggestion(suggested_value, unknown, not_applicable) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 64 def detect_abstractor_suggestion(suggested_value, unknown, not_applicable) abstractor_suggestion = nil abstractor_suggestion = abstractor_suggestions(true).detect do |abstractor_suggestion| abstractor_suggestion.suggested_value == suggested_value && abstractor_suggestion.unknown == unknown && abstractor_suggestion.not_applicable == not_applicable end end |
#display_value ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 52 def display_value if unknown 'unknown' elsif not_applicable 'not applicable' elsif value.blank? '[Not set]' else value end end |
#matching_abstractor_suggestions ⇒ Object
45 46 47 48 49 50 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 45 def matching_abstractor_suggestions unknown_values = unknown ? unknown : [unknown, nil] not_applicable_values = not_applicable ? not_applicable : [not_applicable, nil] suggested_values = value.blank? ? ['', nil] : value abstractor_suggestions.where(unknown: unknown_values, not_applicable: not_applicable_values, suggested_value: suggested_values) end |
#review_matching_suggestions ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 37 def review_matching_suggestions accepted_status = Abstractor::AbstractorSuggestionStatus.where(:name => 'Accepted').first matching_abstractor_suggestions.each do |abstractor_suggestion| abstractor_suggestion.abstractor_suggestion_status = accepted_status abstractor_suggestion.save! end end |
#unreviewed? ⇒ Boolean
Determines if the abstraction has been reviewed.
77 78 79 |
# File 'lib/abstractor/methods/models/abstractor_abstraction.rb', line 77 def unreviewed? (value.blank? && unknown.blank? && not_applicable.blank?) end |