Class: SearchKit::Models::Events

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents = []) ⇒ Events

Returns a new instance of Events.



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

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

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



10
11
12
# File 'lib/search_kit/models/events.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/events.rb', line 10

def member_class
  @member_class
end

Class Method Details

.[](*arguments) ⇒ Object



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

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

Instance Method Details

#<<(new_event) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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