Module: Magnum::Payload

Defined in:
lib/magnum/payload.rb,
lib/magnum/payload/base.rb,
lib/magnum/payload/errors.rb,
lib/magnum/payload/version.rb

Defined Under Namespace

Modules: MessageParser Classes: Base, Beanstalk, Bitbucket, Custom, Error, Github, Gitlab, ParseError, PayloadError

Constant Summary collapse

SOURCES =
%w(custom github gitlab bitbucket beanstalk)
VERSION =
"0.6.0"

Class Method Summary collapse

Class Method Details

.parse(source, payload) ⇒ Object


20
21
22
23
24
25
26
27
# File 'lib/magnum/payload.rb', line 20

def self.parse(source, payload)
  unless valid_source?(source)
    raise PayloadError, "Invalid payload type: #{source}"
  end

  klass = Magnum::Payload.const_get(source.to_s.capitalize)
  klass.new(payload)
end

.valid_source?(source) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/magnum/payload.rb', line 16

def self.valid_source?(source)
  SOURCES.include?(source.to_s)
end