Sha256: 800c24293565753e940c14cb37a495854a7030f8279c4828f3bb435c7fda4c90

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

module Screengem
  #
  # Concern for adding dampening to primitives.
  #
  module Dampenable
    extend ActiveSupport::Concern

    class_methods do
      #
      # Since most primitives may be dampened.
      #
      def supports_dampening?
        true
      end

      #
      # Specify a primitive subclass with no dampening.
      #
      def skip_dampening
        define_singleton_method(:supports_dampening?) do
          false
        end
      end

      #
      # Specify the dampening configuration scope.
      #
      def dampen_scope(scope)
        define_method(:dampening_scope) do
          scope
        end
      end
    end

    def seconds_to_dampen
      dampen_configuration.seconds_to_dampen(dampening_scope, self.class.name)
    end

    private

    def dampen_configuration
      Screengem::DampenConfiguration.instance.configuration
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
screengem-0.1.2 lib/screengem/concerns/dampenable.rb
screengem-0.1.1 lib/screengem/concerns/dampenable.rb
screengem-0.1.0 lib/screengem/concerns/dampenable.rb