Module: Dam

Defined in:
lib/dam.rb,
lib/dam/stream.rb,
lib/dam/storage.rb,
lib/dam/version.rb,
lib/dam/activity.rb

Defined Under Namespace

Classes: Activity, ActivityType, Context, ParamsProxy, Storage, Stream, StreamDefinition, TemplatedStream, TypeProxy

Constant Summary collapse

PLACEHOLDER_PATTERN =
%r{:[^:@/-]+}
Version =
"0.2.0"

Class Method Summary collapse

Class Method Details

.activity(name, &block) ⇒ Object



23
24
25
26
27
# File 'lib/dam.rb', line 23

def self.activity(name, &block)
  act = Dam::ActivityType.new(name, &block)
  Dam::ActivityType.register(name, act)
  act
end

.post(type, params = {}) ⇒ Object



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

def self.post(type, params = {})
  act = Dam::ActivityType.lookup(type.to_sym).apply(params)

  act.post!
  
  act
end

.push(activity) ⇒ Object



9
10
11
12
13
# File 'lib/dam.rb', line 9

def self.push(activity)
  Dam::Stream.all.select {|stream| stream.matches? activity }.each do |stream|
    Dam::Storage.insert(stream, activity)
  end
end

.stream(name, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dam.rb', line 29

def self.stream(name, &block)
  definition = StreamDefinition.new
  definition.instance_eval(&block)
  
  stream = if Stream.has_placeholder? name
    TemplatedStream.new(name, definition)
  else
    Stream.new(name, definition)
  end
  Dam::Stream.register(name, stream)
end