Class: Daedal::Attributes::ScoreFunctionArray
- Inherits:
-
Array
- Object
- Array
- Daedal::Attributes::ScoreFunctionArray
- Defined in:
- lib/daedal/attributes/score_function_array.rb
Instance Method Summary collapse
- #<<(function) ⇒ Object
- #unshift(function) ⇒ Object
-
#valid_score_function?(score_function) ⇒ Boolean
Values should be an array of hashes with filter & weight.
Instance Method Details
#<<(function) ⇒ Object
5 6 7 8 9 |
# File 'lib/daedal/attributes/score_function_array.rb', line 5 def <<(function) raise Virtus::CoercionError.new(value, 'Daedal::Attributes::ScoreFunction') unless valid_score_function?(function) super function end |
#unshift(function) ⇒ Object
11 12 13 14 15 |
# File 'lib/daedal/attributes/score_function_array.rb', line 11 def unshift(function) raise Virtus::CoercionError.new(f, 'Daedal::Attributes::ScoreFunctions') unless valid_score_function?(function) super function end |
#valid_score_function?(score_function) ⇒ Boolean
Values should be an array of hashes with filter & weight
19 20 21 |
# File 'lib/daedal/attributes/score_function_array.rb', line 19 def valid_score_function?(score_function) score_function[:filter].respond_to?(:hash) && score_function[:weight].respond_to?(:hash) end |