Class: Rpush::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/rpush/plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Plugin

Returns a new instance of Plugin.



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

def initialize(name)
  @name = name
  @url = nil
  @description = nil
  @config = OpenStruct.new
  @reflection_collection = Rpush::ReflectionCollection.new
  @init_block = -> {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/rpush/plugin.rb', line 12

def config
  @config
end

#descriptionObject

Returns the value of attribute description.



13
14
15
# File 'lib/rpush/plugin.rb', line 13

def description
  @description
end

#init_blockObject (readonly)

Returns the value of attribute init_block.



12
13
14
# File 'lib/rpush/plugin.rb', line 12

def init_block
  @init_block
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/rpush/plugin.rb', line 12

def name
  @name
end

#urlObject

Returns the value of attribute url.



13
14
15
# File 'lib/rpush/plugin.rb', line 13

def url
  @url
end

Instance Method Details

#configure {|@config| ... } ⇒ Object

Yields:



30
31
32
33
# File 'lib/rpush/plugin.rb', line 30

def configure
  yield(@config)
  Rpush.config.plugin.send("#{@name}=", @config)
end

#init(&block) ⇒ Object



35
36
37
# File 'lib/rpush/plugin.rb', line 35

def init(&block)
  @init_block = block
end

#reflect {|@reflection_collection| ... } ⇒ Object

Yields:

  • (@reflection_collection)


24
25
26
27
28
# File 'lib/rpush/plugin.rb', line 24

def reflect
  yield(@reflection_collection)
  return if Rpush.reflection_stack.include?(@reflection_collection)
  Rpush.reflection_stack << @reflection_collection
end

#unloadObject



39
40
41
42
# File 'lib/rpush/plugin.rb', line 39

def unload
  Rpush.reflection_stack.delete(@reflection_collection)
  Rpush.config.plugin.send("#{name}=", nil)
end