Sha256: 3747ceaa4929d707e8b47d751c5bd4f287f1bbc0131cb263332b0dc5cea9dd78
Contents?: true
Size: 829 Bytes
Versions: 4
Compression:
Stored size: 829 Bytes
Contents
# frozen_string_literal: true module Stance class Events include ActiveSupport::Callbacks attr_reader :event define_callbacks :create class << self attr_accessor :events def inherited(child) @events ||= {} child.events ||= @events.dup super end def event(name, options = {}) @events ||= {} sname = name.to_s raise DuplicateEvent, "Cannot redefine event :#{sname} on #{self}" if @events.key?(sname) @events[sname] = options end def before_create(*methods, &block) set_callback :create, :before, *methods, &block end def after_create(*methods, &block) set_callback :create, :after, *methods, &block end end def initialize(event) @event = event end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
stance-0.8.3 | lib/stance/events.rb |
stance-0.8.2 | lib/stance/events.rb |
stance-0.8.1 | lib/stance/events.rb |
stance-0.8.0 | lib/stance/events.rb |