Class: SearchKit::Models::Keys

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/search_kit/models/keys.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents = []) ⇒ Keys

Returns a new instance of Keys.



12
13
14
15
# File 'lib/search_kit/models/keys.rb', line 12

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



10
11
12
# File 'lib/search_kit/models/keys.rb', line 10

def contents
  @contents
end

#member_classObject (readonly)

Returns the value of attribute member_class.



10
11
12
# File 'lib/search_kit/models/keys.rb', line 10

def member_class
  @member_class
end

Class Method Details

.[](*arguments) ⇒ Object



6
7
8
# File 'lib/search_kit/models/keys.rb', line 6

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

Instance Method Details

#<<(new_key) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/search_kit/models/keys.rb', line 17

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

#creatorObject



29
30
31
# File 'lib/search_kit/models/keys.rb', line 29

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

#each(&block) ⇒ Object



25
26
27
# File 'lib/search_kit/models/keys.rb', line 25

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

#tokensObject



33
34
35
# File 'lib/search_kit/models/keys.rb', line 33

def tokens
  contents.map(&:token)
end