Module: Roll::Attributes

Included in:
Package, Package::Contents, Package::Control, Package::Security, Package::Version
Defined in:
lib/roll/attributes.rb

Overview

Attributes DSL

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/roll/attributes.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'lib/roll/attributes.rb', line 11

def valid?
  begin
    validate
    return true
  rescue ValidationError
    return false
  end
end

#validateObject Also known as: assert_valid



21
22
23
24
25
# File 'lib/roll/attributes.rb', line 21

def validate
  self.class.validation.each do |message, block|
    raise(ValidationError, message) unless instance_eval(&block)
  end
end