Sha256: 36d8d9509cda5bf18f377c2a8dc9699e8e9c2096dbeee3145c46455290c601af

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

# Copyright (c) 2012 MaxMedia and Travis Warlick
# Licensed under the MIT License (see LICENSE)

class Module
  # Defines a DSL attribute accessor (or more than one)
  # 
  # @param names [*Symbol, *String] list of accessors to create
  #
  # @example Define an accessor
  #   module Foo
  #     class_dsl_attr_accessor :foo, :bar
  #   ene
  #   class Bar
  #     include Foo
  #     foo "fooey"
  #     bar foo+" foobar"
  #   end
  #   Bar.foo # => "fooey"
  #   Bar.bar # => "fooey foobar"
  def class_dsl_attr_accessor(*names)
    names.each do |name|
      class_eval <<-EOC, __FILE__, __LINE__+1
        def self.#{name}(val=nil)
          (val ? self.#{name} = val : @#{name})
        end
      EOC
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dionysus-2.2.0.0.pre1 lib/dionysus/module/class_dsl_attr.rb