Class: Class

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

Instance Method Summary collapse

Instance Method Details

#typed_attr_accessor(name, type) ⇒ Object

Raises:

  • (TypeException)


5
6
7
8
9
10
11
12
13
# File 'lib/rusql.rb', line 5

def typed_attr_accessor(name, type)
  raise TypeException.new(Class, type.class) unless type.is_a?(Class)

  instance_eval { attr_reader name }
  
  define_method "#{name}=", Proc.new { |val|
    instance_variable_set("@#{name}", val)
  }
end