Module: Ghaki::Bool::Accessors

Defined in:
lib/ghaki/bool/accessors.rb

Overview

Boolean attribute helpers.

Instance Method Summary collapse

Instance Method Details

#attr_reader_bool_writer(*attrs) ⇒ Object

Generate normal getter and boolean style setter.



48
49
50
51
# File 'lib/ghaki/bool/accessors.rb', line 48

def attr_reader_bool_writer *attrs
  class_eval do attr_reader *attrs end
  bool_writer *attrs
end

#bool_accessor(*attrs) ⇒ Object

Generate boolean style getter and setter.



60
61
62
63
# File 'lib/ghaki/bool/accessors.rb', line 60

def bool_accessor *attrs
  bool_reader *attrs
  bool_writer *attrs
end

#bool_attr_accessor(*attrs) ⇒ Object

Generate normal and boolean style getters and setters.



42
43
44
45
# File 'lib/ghaki/bool/accessors.rb', line 42

def bool_attr_accessor *attrs
  class_eval do attr_accessor *attrs end
  bool_accessor *attrs
end

#bool_attr_reader(*attrs) ⇒ Object

Generate normal getter and boolean style.



30
31
32
33
# File 'lib/ghaki/bool/accessors.rb', line 30

def bool_attr_reader *attrs
  class_eval do attr_reader *attrs end
  bool_reader *attrs
end

#bool_attr_writer(*attrs) ⇒ Object

Generate normal setter and boolean style.



36
37
38
39
# File 'lib/ghaki/bool/accessors.rb', line 36

def bool_attr_writer *attrs
  class_eval do attr_writer *attrs end
  bool_writer *attrs
end

#bool_reader(*attrs) ⇒ Object

Generate boolean style getter.



8
9
10
11
12
13
14
15
16
# File 'lib/ghaki/bool/accessors.rb', line 8

def bool_reader *attrs
  attrs.each do |name|
    class_eval <<-"END"
      def #{name}?
        @#{name}
      end
    END
  end
end

#bool_reader_attr_writer(*attrs) ⇒ Object

Generate boolean style getter and normal setter.



54
55
56
57
# File 'lib/ghaki/bool/accessors.rb', line 54

def bool_reader_attr_writer *attrs
  bool_reader *attrs
  class_eval do attr_writer *attrs end
end

#bool_writer(*attrs) ⇒ Object

Generate boolean style setter.



19
20
21
22
23
24
25
26
27
# File 'lib/ghaki/bool/accessors.rb', line 19

def bool_writer *attrs
  attrs.each do |name|
    class_eval <<-"END"
      def #{name}! val=true
        @#{name} = val
      end
    END
  end
end