Module: ValidatedAccessors

Defined in:
lib/validated_accessors.rb

Overview

Copyright © 2014 Eloy Espinaco, Gastón Ramos

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#validated_accessor(attribute, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/validated_accessors.rb', line 7

def validated_accessor attribute, options

  define_method attribute do
    instance_variable_get "@#{ attribute }"
  end

  define_method "#{ attribute }=" do |value|
    instance_variable_set "@#{ attribute }", value
  end

end