Sha256: 4cf2be3855ad405b54d5a9c4e1ac8708bc120f06e066a4ce64e0e73de10090b7

Contents?: true

Size: 728 Bytes

Versions: 8

Compression:

Stored size: 728 Bytes

Contents

module SearchKit
  module Models
    class Keys
      include Enumerable

      def self.[](*arguments)
        new(arguments)
      end

      attr_reader :contents, :member_class

      def initialize(contents = [])
        @contents     = contents
        @member_class = SearchKit::Models::Key
      end

      def <<(new_key)
        case new_key
        when Hash         then contents << member_class.new(new_key)
        when member_class then contents << new_key
        else contents
        end
      end

      def each(&block)
        contents.each(&block)
      end

      def creator
        self.class.new(select(&:creator?))
      end

      def tokens
        contents.map(&:token)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
search-kit-0.0.10 lib/search_kit/models/keys.rb
search-kit-0.0.9 lib/search_kit/models/keys.rb
search-kit-0.0.8 lib/search_kit/models/keys.rb
search-kit-0.0.7 lib/search_kit/models/keys.rb
search-kit-0.0.6 lib/search_kit/models/keys.rb
search-kit-0.0.5 lib/search_kit/models/keys.rb
search-kit-0.0.4 lib/search_kit/models/keys.rb
search-kit-0.0.3 lib/search_kit/models/keys.rb