Sha256: 4c0447f802c408c1fa0a2539ffe9a0e0f65f6efbe630428fe582d784a05dd0ad

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

class Eco::Data::Locations::NodeDiff::NodesDiff
  module Selectors
    # Creates selector methods on `diffs` (nodes that changed)
    # It also creates a method with question mark that evaluates true if **any** diff matches.
    # @note the selector method name with a question mark should exist in the `diff_result_class`
    def selector(*attrs)
      attrs.each do |attr|
        meth  = attr.to_sym
        methq = "#{meth}?".to_sym
        define_method meth do
          diffs.select(&methq)
        end

        define_method methq do
          diffs.any?(&methq)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eco-helpers-2.7.4 lib/eco/data/locations/node_diff/nodes_diff/selectors.rb
eco-helpers-2.7.2 lib/eco/data/locations/node_diff/nodes_diff/selectors.rb
eco-helpers-2.7.1 lib/eco/data/locations/node_diff/nodes_diff/selectors.rb
eco-helpers-2.7.0 lib/eco/data/locations/node_diff/nodes_diff/selectors.rb