Class: Module

Inherits:
Object show all
Defined in:
lib/sprinkle/extensions/dsl_accessor.rb

Overview

:nodoc:

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/sprinkle/extensions/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