Module: Moneta::Defaults::ClassMethods Private

Defined in:
lib/moneta/defaults.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#featuresArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns features list

Returns:

  • (Array<Symbol>)

    list of features



12
13
14
# File 'lib/moneta/defaults.rb', line 12

def features
  @features ||= superclass.respond_to?(:features) ? superclass.features : [].freeze
end

#not_supports(*features) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declares that this adapter does not support the given feature, and adds a stub method that raises a NotImplementedError. Useful when inheriting from another adapter.

Examples:

class MyAdapter < OtherAdapterWithCreate
  include Moneta::Defaults
  not_supports :create
end


39
40
41
42
43
44
45
46
47
# File 'lib/moneta/defaults.rb', line 39

def not_supports(*features)
  features.each do |feature|
    define_method(feature) do
      raise ::NotImplementedError, "#{feature} not supported"
    end
  end

  @features = (self.features - features).freeze
end

#supports(*features) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declares that this adapter supports the given feature.

Examples:

class MyAdapter
  include Moneta::Defaults
  supports :create
  def create(key, value, options = {})
    # implement create!
  end
end


26
27
28
# File 'lib/moneta/defaults.rb', line 26

def supports(*features)
  @features = (self.features | features).freeze
end