Sha256: b1e3cdfd4179da93c177d9e5fe1907cde33bd7f80646be5c790538b14f6507e8

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 KB

Contents

module Arcabouco

  class << self
    def mattr_reader(*syms)
      syms.each do |sym|
        raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/
        class_eval(<<-EOS, __FILE__, __LINE__ + 1)
        @@#{sym} = nil unless defined? @@#{sym}
        def self.#{sym}
          @@#{sym}
        end
        EOS

        class_variable_set("@@#{sym}", yield) if block_given?
      end
    end

    def mattr_writer(*syms)
      syms.each do |sym|
        raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/
        class_eval(<<-EOS, __FILE__, __LINE__ + 1)
        @@#{sym} = nil unless defined? @@#{sym}
        def self.#{sym}=(obj)
          @@#{sym} = obj
        end
        EOS

        send("#{sym}=", yield) if block_given?
      end
    end

    def mattr_accessor(*syms, &blk)
      mattr_reader(*syms, &blk)
      mattr_writer(*syms, &blk)
    end
  end

  mattr_accessor :root
  mattr_accessor :gem_root
  mattr_accessor :asset_list
  mattr_accessor :application_name
 
  self.asset_list = %w(app.css app.js app.vendor.js app.vendor.css *.png *.jpg *.gif *.mp3 *.wav)
  self.application_name = "Arcabouco Application"

  def self.setup
    yield self
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
arcabouco-0.2.16 lib/arcabouco/base.rb
arcabouco-0.2.15 lib/arcabouco/base.rb
arcabouco-0.2.14 lib/arcabouco/base.rb
arcabouco-0.2.13 lib/arcabouco/base.rb
arcabouco-0.2.12 lib/arcabouco/base.rb
arcabouco-0.2.11 lib/arcabouco/base.rb
arcabouco-0.2.10 lib/arcabouco/base.rb
arcabouco-0.2.9 lib/arcabouco/base.rb
arcabouco-0.2.8 lib/arcabouco/base.rb
arcabouco-0.2.7 lib/arcabouco/base.rb
arcabouco-0.2.6 lib/arcabouco/base.rb
arcabouco-0.2.5 lib/arcabouco/base.rb
arcabouco-0.2.4 lib/arcabouco/base.rb
arcabouco-0.2.3 lib/arcabouco/base.rb
arcabouco-0.2.2 lib/arcabouco/base.rb
arcabouco-0.2.1 lib/arcabouco/base.rb