Class: YaAcl::Assert
- Inherits:
-
Object
- Object
- YaAcl::Assert
- Defined in:
- lib/ya_acl/assert.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #allow?(params) ⇒ Boolean
-
#initialize(name, param_names, &block) ⇒ Assert
constructor
A new instance of Assert.
Constructor Details
#initialize(name, param_names, &block) ⇒ Assert
Returns a new instance of Assert.
5 6 7 8 9 10 11 12 13 |
# File 'lib/ya_acl/assert.rb', line 5 def initialize(name, param_names, &block) @name = name.to_sym @param_names = param_names @block = block @param_names.each do |name| self.class.send :attr_accessor, name end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/ya_acl/assert.rb', line 3 def name @name end |
Instance Method Details
#allow?(params) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ya_acl/assert.rb', line 15 def allow?(params) if @param_names != (@param_names & params.keys) raise "Params for assert '#{name}': #{@param_names.inspect}" end @param_names.each do |name| self.send "#{name}=", params[name] end instance_eval &@block end |