Class: Predicated::Constraint

Inherits:
Object
  • Object
show all
Defined in:
lib/predicated/constrain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Constraint

Returns a new instance of Constraint.



35
36
37
38
39
# File 'lib/predicated/constrain.rb', line 35

def initialize(args)
  @name = args[:name]
  @selectors = args[:selectors] || [:all]
  @check_that = args[:check_that]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



34
35
36
# File 'lib/predicated/constrain.rb', line 34

def name
  @name
end

#selectorsObject (readonly)

Returns the value of attribute selectors.



34
35
36
# File 'lib/predicated/constrain.rb', line 34

def selectors
  @selectors
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
# File 'lib/predicated/constrain.rb', line 45

def ==(other)
  @name == other.name && @selectors == other.selectors
end

#check(predicate, ancestors) ⇒ Object



41
42
43
# File 'lib/predicated/constrain.rb', line 41

def check(predicate, ancestors)
  @check_that.call(predicate, ancestors)
end