Class: Miasma::Models::Orchestration::Stack::Events

Inherits:
Types::Collection show all
Defined in:
lib/miasma/models/orchestration/events.rb

Overview

Abstract stack resources collection

Instance Attribute Summary collapse

Attributes inherited from Types::Collection

#api

Instance Method Summary collapse

Methods inherited from Types::Collection

#all, #from_json, #get, #reload, #to_json

Methods included from Utils::ApiMethoding

#api_method_for

Constructor Details

#initialize(stack) ⇒ Events

Override to capture originating stack

Parameters:



17
18
19
20
# File 'lib/miasma/models/orchestration/events.rb', line 17

def initialize(stack)
  @stack = stack
  super stack.api
end

Instance Attribute Details

#stackMiasma::Models::Orchestration::Stack (readonly)



12
13
14
# File 'lib/miasma/models/orchestration/events.rb', line 12

def stack
  @stack
end

Instance Method Details

#build(args = {}) ⇒ Event

Build a new event instance

Parameters:

  • args (Hash) (defaults to: {})

    creation options

Returns:



34
35
36
# File 'lib/miasma/models/orchestration/events.rb', line 34

def build(args = {})
  Event.new(stack, args.to_smash)
end

#filter(options = {}) ⇒ Array<Event>

Return events matching given filter

Parameters:

  • options (Hash) (defaults to: {})

    filter options

Returns:

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/miasma/models/orchestration/events.rb', line 26

def filter(options = {})
  raise NotImplementedError
end

#modelEvent

Returns collection item class.

Returns:

  • (Event)

    collection item class



39
40
41
# File 'lib/miasma/models/orchestration/events.rb', line 39

def model
  Event
end

#update!Array<Event>

Fetch any new events and add to collection

Returns:

  • (Array<Event>)

    new events fetched



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/miasma/models/orchestration/events.rb', line 46

def update!
  if memoized?(:collection)
    current_events = all
    if api.respond_to?(:event_all_new)
      new_events = api.event_all_new(self)
      unmemoize(:collection)
      memoize(:collection) do
        new_events + current_events
      end
      new_events
    else
      all - current_events
    end
  else
    all
  end
end