Class: SilverMother::Event

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/silver_mother/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_cacheObject (readonly)

Returns the value of attribute event_cache.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def event_cache
  @event_cache
end

#feed_uidsObject (readonly)

Returns the value of attribute feed_uids.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def feed_uids
  @feed_uids
end

#feedsObject (readonly)

Returns the value of attribute feeds.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def feeds
  @feeds
end

#node_uidsObject (readonly)

Returns the value of attribute node_uids.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def node_uids
  @node_uids
end

#nodesObject (readonly)

Returns the value of attribute nodes.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def nodes
  @nodes
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/silver_mother/event.rb', line 7

def token
  @token
end

#ttlsObject (readonly)

Returns the value of attribute ttls.



8
9
10
# File 'lib/silver_mother/event.rb', line 8

def ttls
  @ttls
end

Instance Method Details

#call(token) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/silver_mother/event.rb', line 15

def call(token)
  @token     = token
  @feeds_api = SilverMother::Feed.instance
  @feeds_api.call(@token)
  @nodes_api = SilverMother::Node.instance
  @nodes_api.call(@token)
end

#clear_cache!Object



50
51
52
53
# File 'lib/silver_mother/event.rb', line 50

def clear_cache!
  @event_cache = {}
  @ttls        = {}
end

#events(uid, type = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/silver_mother/event.rb', line 39

def events(uid, type = nil)
  @event_cache ||= {}
  @ttls ||= {}
  clear_cache(uid) if expired?(@ttls[uid])
  @ttls[uid] ||= ttl(TTL)
  @event_cache[uid] ||= Api.instance
                           .get(path(uid, type), @token)
                           .to_ostruct
                           .objects
end