Class: Streama::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/streama/definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ Definition

Returns a new instance of Definition.

Parameters:



8
9
10
11
12
13
# File 'lib/streama/definition.rb', line 8

def initialize(definition)
  @name = definition[:name]
  @actor = definition[:actor] || {}
  @object = definition[:object] || {}
  @target_object = definition[:target_object] || {}
end

Instance Attribute Details

#actorObject (readonly)

Returns the value of attribute actor.



5
6
7
# File 'lib/streama/definition.rb', line 5

def actor
  @actor
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/streama/definition.rb', line 5

def name
  @name
end

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/streama/definition.rb', line 5

def object
  @object
end

#receiversObject (readonly)

Returns the value of attribute receivers.



5
6
7
# File 'lib/streama/definition.rb', line 5

def receivers
  @receivers
end

#target_objectObject (readonly)

Returns the value of attribute target_object.



5
6
7
# File 'lib/streama/definition.rb', line 5

def target_object
  @target_object
end

Class Method Details

.find(name) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/streama/definition.rb', line 33

def self.find(name)
  unless definition = registered.find{|definition| definition.name == name.to_sym}
    raise Streama::Errors::InvalidActivity, "Could not find a definition for `#{name}`"
  else
    definition
  end
end

.register(definition) ⇒ Definition

Registers a new definition

Parameters:

  • definition (Definition)

    The definition to register

Returns:

  • (Definition)

    Returns the registered definition



20
21
22
23
24
25
# File 'lib/streama/definition.rb', line 20

def self.register(definition)
  return false unless definition.is_a? DefinitionDSL
  definition = new(definition)
  self.registered << definition
  return definition || false
end

.registeredArray<Streama::Definition>

List of registered definitions

Returns:



29
30
31
# File 'lib/streama/definition.rb', line 29

def self.registered
  @definitions ||= []
end