Class: SmartProperties::Validations::Ancestor

Inherits:
Object
  • Object
show all
Includes:
SmartProperties
Defined in:
lib/smart_properties/validations/ancestor.rb

Constant Summary

Constants included from SmartProperties

SmartProperties::VERSION

Instance Method Summary collapse

Methods included from SmartProperties

#[], #[]=, #initialize

Instance Method Details

#to_procObject



13
14
15
16
# File 'lib/smart_properties/validations/ancestor.rb', line 13

def to_proc
  validator = self
  ->(klass) { validator.validate(klass) }
end

#to_sObject



18
19
20
# File 'lib/smart_properties/validations/ancestor.rb', line 18

def to_s
  "subclasses of #{type.to_s}"
end

#validate(klass) ⇒ Object



9
10
11
# File 'lib/smart_properties/validations/ancestor.rb', line 9

def validate(klass)
  klass.is_a?(Class) && klass < type
end