Module: DslAccessor::Macros

Defined in:
lib/support/dsl_accessor.rb

Instance Method Summary collapse

Instance Method Details

#dsl_accessor(*keys) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/support/dsl_accessor.rb', line 7

def dsl_accessor(*keys)
  keys.map(&:to_s).each do |k|
    class_eval <<-ACCESSORS
      attr_writer :#{k}
      def #{k}(v = nil)
        if v
          @#{k} = v
        else
          @#{k}
        end
      end
    ACCESSORS
  end
end