Module: Arcabouco

Defined in:
lib/arcabouco/cmd.rb,
lib/arcabouco/base.rb,
lib/arcabouco/server.rb,
lib/arcabouco/version.rb,
lib/arcabouco/application.rb

Defined Under Namespace

Classes: Application, Command, Server, WebServer

Constant Summary collapse

VERSION =
"0.2.14"

Class Method Summary collapse

Class Method Details

.mattr_accessor(*syms, &blk) ⇒ Object



32
33
34
35
# File 'lib/arcabouco/base.rb', line 32

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

.mattr_reader(*syms) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/arcabouco/base.rb', line 4

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

.mattr_writer(*syms) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/arcabouco/base.rb', line 18

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

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Arcabouco)

    the object that the method was called on



46
47
48
# File 'lib/arcabouco/base.rb', line 46

def self.setup
  yield self
end