Sha256: df73ba01f010f78fa76b8e06250835dc00e240f3c84dd5061e749081e9c531d6

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

module Yaps
  module Publisher
    extend ActiveSupport::Concern
    module ClassMethods
      def published(opts = {})
        options = opts.clone
        include_default_actions(options)
        nil
      end

      def include_default_actions(options)
        defaults = {
          create:  Creation,
          destroy: Destruction,
          update:  Updation
        }

        modules = if options[:except]
          defaults.except(*options[:except])
        elsif options[:only]
          defaults.slice(*options[:only])
        else
          defaults
        end

        modules.each do |key, value|
          include value
        end
      end

      def available_options
        [:only, :except].freeze
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yaps-0.0.1 lib/yaps/publisher.rb