Sha256: 134ef5352a61348b488dbc4024d6d9aff1e64e859ecff3d87884fd4d13dd37d7

Contents?: true

Size: 508 Bytes

Versions: 2

Compression:

Stored size: 508 Bytes

Contents

require "oj"

module Octogate
  class Event::Base < Octogate::Model
    class << self
      def register_event(name, klass)
        Octogate::Event.register_event(name, klass)
        self.instance_eval do
          define_method :name do
            name
          end
        end
      end

      def parse(delivery_id, json)
        payload = Oj.load(json).deep_symbolize_keys

        new(payload.merge(delivery_id: delivery_id))
      end
    end

    def default_condition
      true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octogate-0.4.0 lib/octogate/events/base.rb
octogate-0.3.0 lib/octogate/events/base.rb