Sha256: e185ca3b343a212a77fc87a8d78c70739ee0543ed6443382e9aaa05e1d7857db

Contents?: true

Size: 705 Bytes

Versions: 9

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module Signum
  module ActiveRecordHelpers
    extend ActiveSupport::Concern

    class_methods do
      def signalable
        has_many :signals, as: :signalable, class_name: 'Signum::Signal'

        send :include, Signum::ActiveRecordHelpers::InstanceMethods
        extend(Signum::ActiveRecordHelpers::ClassMethods)
      end
    end

    module ClassMethods
    end

    module InstanceMethods
      def online!
        update(presence: 'online')
      end

      def offline!
        update(presence: 'offline')
      end

      def appeared!
        update(presence: 'appeared')
      end

      def away!
        update(presence: 'away')
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
signum-0.6.0 lib/signum/active_record_helpers.rb
signum-0.5.1 lib/signum/active_record_helpers.rb
signum-0.5.0 lib/signum/active_record_helpers.rb
signum-0.4.13 lib/signum/active_record_helpers.rb
signum-0.4.12 lib/signum/active_record_helpers.rb
signum-0.4.11 lib/signum/active_record_helpers.rb
signum-0.4.10 lib/signum/active_record_helpers.rb
signum-0.4.8 lib/signum/active_record_helpers.rb
signum-0.3.12 lib/signum/active_record_helpers.rb