lib/evil/client/policy.rb in evil-client-2.0.0 vs lib/evil/client/policy.rb in evil-client-2.1.0
- old
+ new
@@ -2,55 +2,55 @@
#
# Base class for policies that validate settings
#
class Policy < Tram::Policy
class << self
- # Subclasses itself for a settings class
+ # Subclasses itself for a model class
#
- # @param [Class] settings Settings class to validate
+ # @param [Class] model Settings class to validate
# @return [Class]
#
- def for(settings)
+ def for(model)
Class.new(self).tap do |klass|
- klass.send :instance_variable_set, :@settings, settings
+ klass.send :instance_variable_set, :@model, model
end
end
- # Reference to the settings class whose instances validates the policy
+ # Reference to the model whose instances are validated by the policy
#
# @return [Class, nil]
#
- attr_reader :settings
+ attr_reader :model
- # Delegates the name of the policy to the name of checked settings
+ # Delegates the name of the policy to the name of checked model
#
# @return [String, nil]
#
def name
- "#{settings}.policy"
+ "#{model}.policy"
end
alias_method :to_s, :name
alias_method :to_sym, :name
alias_method :inspect, :name
private
def scope
@scope ||= %i[evil client errors] << \
- Tram::Policy::Inflector.underscore(settings.to_s)
+ Tram::Policy::Inflector.underscore(model.to_s)
end
end
# An instance of settings to be checked by the policy
- param :settings
+ param :model
private
def respond_to_missing?(name, *)
- settings.respond_to?(name)
+ model.respond_to?(name)
end
def method_missing(*args)
- respond_to_missing?(*args) ? settings.__send__(*args) : super
+ respond_to_missing?(*args) ? model.__send__(*args) : super
end
end
end