Class: Gwooks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gwooks/base.rb

Constant Summary collapse

DSL_METHODS =
%w(
  after
  before
  branch
  commits_added
  commits_author_email
  commits_author_name
  commits_id
  commits_message
  commits_modified
  commits_removed
  commits_timestamp
  commits_url
  ref
  repository_description
  repository_forks
  repository_homepage
  repository_name
  repository_owner_email
  repository_owner_name
  repository_pledgie
  repository_private
  repository_url
  repository_watchers
)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Base

Returns a new instance of Base.



73
74
75
# File 'lib/gwooks/base.rb', line 73

def initialize(payload)
  @payload = Gwooks::Payload.new(payload)
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



71
72
73
# File 'lib/gwooks/base.rb', line 71

def payload
  @payload
end

Class Method Details

.call(payload) ⇒ Object



33
34
35
# File 'lib/gwooks/base.rb', line 33

def call(payload)
  new(payload).call
end

.hooksObject



37
38
39
# File 'lib/gwooks/base.rb', line 37

def hooks
  @_hooks ||= []
end

.payload_matches(key, pattern, &block) ⇒ Object



41
42
43
44
# File 'lib/gwooks/base.rb', line 41

def payload_matches(key, pattern, &block)
  @_hooks ||= []
  @_hooks << [key, pattern, block]
end

Instance Method Details

#callObject



77
78
79
80
81
82
83
# File 'lib/gwooks/base.rb', line 77

def call
  self.class.hooks.each do |hook|
    key, pattern, block = *hook
    exec_if_matching( key, pattern, &block )
  end
  nil
end