Class: PostCommit::Hooks::Base
- Inherits:
-
Object
- Object
- PostCommit::Hooks::Base
- Defined in:
- lib/post_commit/hooks/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Hold the authorization options.
-
#options ⇒ Object
readonly
Hold options defined throught the PostCommit::Hooks::Base#set method.
-
#request ⇒ Object
readonly
Hold the latest request object.
-
#response ⇒ Object
readonly
Hold the latest response.
-
#uri ⇒ Object
readonly
Hold the latest uri object.
Class Method Summary collapse
Instance Method Summary collapse
-
#authorize(options = {}) ⇒ Object
Set up the authorization for the current notifier.
-
#convert_to_params(hash) ⇒ Object
:nodoc:.
-
#convert_to_xml(hash) ⇒ Object
:nodoc:.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#post(options = {}) ⇒ Object
:nodoc:.
-
#set(name, value) ⇒ Object
Set an option for the current hook.
Constructor Details
#initialize ⇒ Base
19 20 21 22 |
# File 'lib/post_commit/hooks/base.rb', line 19 def initialize @credentials = {} = {} end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Hold the authorization options.
5 6 7 |
# File 'lib/post_commit/hooks/base.rb', line 5 def credentials @credentials end |
#options ⇒ Object (readonly)
Hold options defined throught the PostCommit::Hooks::Base#set method
17 18 19 |
# File 'lib/post_commit/hooks/base.rb', line 17 def end |
#request ⇒ Object (readonly)
Hold the latest request object
11 12 13 |
# File 'lib/post_commit/hooks/base.rb', line 11 def request @request end |
#response ⇒ Object (readonly)
Hold the latest response
8 9 10 |
# File 'lib/post_commit/hooks/base.rb', line 8 def response @response end |
#uri ⇒ Object (readonly)
Hold the latest uri object
14 15 16 |
# File 'lib/post_commit/hooks/base.rb', line 14 def uri @uri end |
Class Method Details
.inherited(base) ⇒ Object
24 25 26 |
# File 'lib/post_commit/hooks/base.rb', line 24 def self.inherited(base) PostCommit::Hooks.register base.name.split("::").last.downcase.to_sym, base end |
Instance Method Details
#authorize(options = {}) ⇒ Object
Set up the authorization for the current notifier. Each notifier can have its own authorization options.
30 31 32 |
# File 'lib/post_commit/hooks/base.rb', line 30 def ( = {}) @credentials = end |
#convert_to_params(hash) ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/post_commit/hooks/base.rb', line 65 def convert_to_params(hash) # :nodoc: hash end |
#convert_to_xml(hash) ⇒ Object
:nodoc:
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/post_commit/hooks/base.rb', line 46 def convert_to_xml(hash) # :nodoc: xml_node = Proc.new do |name, value, buffer| buffer ||= "" if value.kind_of?(Hash) buffer << "<#{name}>" value.each {|n, v| buffer << xml_node[n, v] } buffer << "</#{name}>" else buffer << "<#{name}><![CDATA[#{value}]]></#{name}>" end buffer end root = hash.keys.first xml_node[root, hash[root]] end |
#post(options = {}) ⇒ Object
:nodoc:
42 43 44 |
# File 'lib/post_commit/hooks/base.rb', line 42 def post( = {}) # :nodoc: raise PostCommit::AbstractMethodError end |
#set(name, value) ⇒ Object
Set an option for the current hook. The available options may vary from hook to hook and may not be available at all.
set :data_type, :json
38 39 40 |
# File 'lib/post_commit/hooks/base.rb', line 38 def set(name, value) [name.to_sym] = value end |