Class: ActivityStream::DefinitionProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/activity_stream/definition_proxy.rb

Overview

Provides a DSL to define an Activity. It is used in Activity.define

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DefinitionProxy

Returns a new instance of DefinitionProxy.

Parameters:

  • name (Symbol)

    The name of the activity



7
8
9
10
11
12
13
14
# File 'lib/activity_stream/definition_proxy.rb', line 7

def initialize(name)
  @attributes = {
    :name => name.to_sym,
    :icon => 'activity_icon.png',
    :metadata => {},
    :template => 'activity'
  }
end

Instance Method Details

#add_metadata(name, opts = {}) ⇒ Object



43
44
45
# File 'lib/activity_stream/definition_proxy.rb', line 43

def (name, opts = {})
  @attributes[:metadata][name] = opts
end

#icon(filename) ⇒ Object

Define the activity’s icon

Parameters:

  • filename (String)

    the icon’s name inside of the ‘public/images/activity_stream/icons` directory



19
20
21
# File 'lib/activity_stream/definition_proxy.rb', line 19

def icon(filename)
  @attributes.store(:icon, filename)
end

#metadata(*args) ⇒ Object

Define metadata for the activity

Parameters:

  • name (Symbol)

    the unique name for the metadata attribute

  • opts (Hash)

    a customizable set of options



27
28
29
30
31
32
# File 'lib/activity_stream/definition_proxy.rb', line 27

def (*args)
  opts = args.extract_options!
  args.each do |name|
    self.(name, opts)
  end
end

#template(template_name) ⇒ Object

Define a custom template

Parameters:

  • name (String)

    the name of the template for this Activity. Should be located in ‘app/views/activities/*`



37
38
39
# File 'lib/activity_stream/definition_proxy.rb', line 37

def template(template_name)
  @attributes.store(template_name)
end