Class: ActsAsNotifiableRedmine::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_notifiable_redmine/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, &block) ⇒ Channel

Returns a new instance of Channel.



6
7
8
9
10
11
12
13
14
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 6

def initialize(id, &block)
  @id         = id.to_sym
  @name       = @id
  @identifier = "channel_#{name}"
  @events     = []
  @target     = "#{name}"

  instance_eval(&block)
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



4
5
6
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 4

def events
  @events
end

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 4

def identifier
  @identifier
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 4

def name
  @name
end

Instance Method Details

#event(name, options = {}) ⇒ Object



31
32
33
34
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 31

def event(name, options = {})
  new_event = Event.new(name, options)
  @events.push(new_event)
end

#target(target) ⇒ Object



17
18
19
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 17

def target(target)
  @target = target
end

#tokenObject



22
23
24
25
26
27
28
# File 'lib/acts_as_notifiable_redmine/channel.rb', line 22

def token
  if @target.is_a?(Proc)
    "#{@name}-#{@target.call(self)}"
  else
    @target
  end
end