Class: Module

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

Instance Method Summary collapse

Instance Method Details

#dsl_accessor(*symbols) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/core_ext/dsl_accessor.rb', line 2

def dsl_accessor(*symbols)
  symbols.each do |sym|
    class_eval %{
      def #{sym}(*val)
        if val.empty?
          @#{sym}
        else
          @#{sym} = val.size == 1 ? val[0] : val
        end
      end
    }
  end
end