Module: AttrBoolean::ClassMethods

Defined in:
lib/attr_boolean.rb

Instance Method Summary collapse

Instance Method Details

#attr_boolean(*args) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/attr_boolean.rb', line 16

def attr_boolean(*args)
  options = args.extract_options!
  raise ArgumentError, "cannot specify options if defining multiple boolean attributes in one call" if args.size > 1 and !options.empty?

  args.each do |boolean|
    boolean = boolean.intern

    self.class_eval { attr_accessor boolean }

    self.define_methods(boolean, options)
  end
end