Sha256: 7167facb6191ffccbbc9570c982075c00650419f1329c731efbdb23d1689be84

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

require 'active_support'

module NotificationSettings
    module SettingLibrary

        extend ActiveSupport::Concern

        included do
            include NotificationSettings::SettingLibrary::InstanceMethods
        end

        module InstanceMethods

            def status
                if self.object.respond_to?(NotificationSettings.configuration.last_seen) && ( Time.now - self.object.send(NotificationSettings.configuration.last_seen) ).round >= NotificationSettings.configuration.idle_after && ( Time.now - self.object.send(NotificationSettings.configuration.last_seen) ).round < NotificationSettings.configuration.offline_after
                    default = 'idle'
                elsif self.object.respond_to?(NotificationSettings.configuration.last_seen) && ( Time.now - self.object.send(NotificationSettings.configuration.last_seen) ).round >= NotificationSettings.configuration.offline_after
                    default = 'offline'
                else
                    'online'
                end
                self[:status] || default
            end

        end

    end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
notification-settings-1.2.5 lib/notification_settings/setting_library.rb
notification-settings-1.2.4 lib/notification_settings/setting_library.rb
notification-settings-1.2.3 lib/notification_settings/setting_library.rb
notification-settings-1.2.2 lib/notification_settings/setting_library.rb
notification-settings-1.2.1 lib/notification_settings/setting_library.rb
notification-settings-1.2.0 lib/notification_settings/setting_library.rb
notification-settings-1.1.2 lib/notification_settings/setting_library.rb
notification-settings-1.1.1 lib/notification_settings/setting_library.rb
notification-settings-1.1.0 lib/notification_settings/setting_library.rb
notification-settings-1.0.0 lib/notification_settings/setting_library.rb
notification-settings-1.0.0.beta11 lib/notification_settings/setting_library.rb