Class: Tzispa::Domain

Inherits:
Object
  • Object
show all
Defined in:
lib/tzispa/domain.rb

Constant Summary collapse

DEFAULT_DOMAIN_NAME =
:default
DEFAULT_DOMAINS_ROOT =
:apps

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = DEFAULT_DOMAIN_NAME, root = DEFAULT_DOMAINS_ROOT) ⇒ Domain

Returns a new instance of Domain.



12
13
14
15
# File 'lib/tzispa/domain.rb', line 12

def initialize(name=DEFAULT_DOMAIN_NAME, root=DEFAULT_DOMAINS_ROOT)
  @name = name
  @root = root
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/tzispa/domain.rb', line 6

def name
  @name
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/tzispa/domain.rb', line 6

def root
  @root
end

Class Method Details

.load(domain, file) ⇒ Object



47
48
49
# File 'lib/tzispa/domain.rb', line 47

def self.load(domain, file)
  self.new(name: domain).load(file)
end

.require(domain, file) ⇒ Object



43
44
45
# File 'lib/tzispa/domain.rb', line 43

def self.require(domain, file)
  self.new(name: domain).require(file)
end

Instance Method Details

#load(file) ⇒ Object



32
33
34
# File 'lib/tzispa/domain.rb', line 32

def load(file)
  Kernel.load "./#{path}/#{file}.rb"
end

#load_dir(dir) ⇒ Object



36
37
38
39
40
41
# File 'lib/tzispa/domain.rb', line 36

def load_dir(dir)
  Dir["./#{path}/#{dir}/*.rb"].each { |file|
    name = file.split('/').last
    Kernel.load "./#{path}/#{dir}/#{name}"
  }
end

#pathObject



17
18
19
# File 'lib/tzispa/domain.rb', line 17

def path
  "#{root.to_s.downcase}/#{name.to_s.downcase}".freeze
end

#require(file) ⇒ Object



21
22
23
# File 'lib/tzispa/domain.rb', line 21

def require(file)
  Kernel.require "./#{path}/#{file}"
end

#require_dir(dir) ⇒ Object



25
26
27
28
29
30
# File 'lib/tzispa/domain.rb', line 25

def require_dir(dir)
  Dir["./#{path}/#{dir}/*.rb"].each { |file|
    name = file.split('/').last.split('.').first
    Kernel.require "./#{path}/#{dir}/#{name}"
  }
end