Sha256: bc6ce0682d19a0c1e26d6ab7cb050ac1a7d17cf782a8ced18d82dd738592e240

Contents?: true

Size: 1.05 KB

Versions: 20

Compression:

Stored size: 1.05 KB

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

      #
      # Specify dampening to apply to a primitive.
      #
      def dampen_for(seconds)
        define_singleton_method(:seconds_to_dampen) do
          seconds
        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

20 entries across 20 versions & 1 rubygems

Version Path
screengem-0.16.0 lib/screengem/concerns/dampenable.rb
screengem-0.15.0 lib/screengem/concerns/dampenable.rb
screengem-0.14.0 lib/screengem/concerns/dampenable.rb
screengem-0.13.0 lib/screengem/concerns/dampenable.rb
screengem-0.12.0 lib/screengem/concerns/dampenable.rb
screengem-0.11.0 lib/screengem/concerns/dampenable.rb
screengem-0.10.1 lib/screengem/concerns/dampenable.rb
screengem-0.10.0 lib/screengem/concerns/dampenable.rb
screengem-0.9.1 lib/screengem/concerns/dampenable.rb
screengem-0.9.0 lib/screengem/concerns/dampenable.rb
screengem-0.8.1 lib/screengem/concerns/dampenable.rb
screengem-0.8.0 lib/screengem/concerns/dampenable.rb
screengem-0.7.3 lib/screengem/concerns/dampenable.rb
screengem-0.7.2 lib/screengem/concerns/dampenable.rb
screengem-0.7.1 lib/screengem/concerns/dampenable.rb
screengem-0.6.0 lib/screengem/concerns/dampenable.rb
screengem-0.5.0 lib/screengem/concerns/dampenable.rb
screengem-0.4.0 lib/screengem/concerns/dampenable.rb
screengem-0.3.0 lib/screengem/concerns/dampenable.rb
screengem-0.2.0 lib/screengem/concerns/dampenable.rb