Module: ApiDef::Support::AttrArray

Included in:
Element
Defined in:
lib/api_def/support/attr_array.rb

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/api_def/support/attr_array.rb', line 3

def self.included(mod)

  mod.class_eval do

    # Create method +name+ with +@name+ for array storage
    def self.attr_array(*names)
      names.flatten.each do |name|
        self.class_eval <<-EOF
        def #{name}
          @#{name} ||= []
        end
        EOF
      end
    end

  end

end