Sha256: 2bf5c7e6cd3c76220f295aac63216483fd5feab8c98453aaf73ca03b47d27e7e

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

# encoding: utf-8

module Selector

  # The condition checks if a value is included to the collection
  #
  # @example (see #[])
  #
  class Collection < Condition

    # @!method initialize(collection)
    # Initializes the condition with a collection of allowed values
    #
    # @param [Enumerable] collection
    #
    def initialize(_)
      super
    end

    # Checks if the array includes the value
    #
    # @example
    #   condition = Set.new [:foo, :bar]
    #   condition[:foo] # => true
    #   condition[:baz] # => false
    #
    # @param (see Selector::Condition#[])
    #
    # @return (see Selector::Condition#[])
    #
    def [](value)
      attribute.include? value
    end

  end # class Collection

end # module Selector

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selector-0.0.3 lib/selector/collection.rb
selector-0.0.2 lib/selector/collection.rb
selector-0.0.1 lib/selector/collection.rb