Class: Tzispa::Domain
- Inherits:
-
Object
- Object
- Tzispa::Domain
- Defined in:
- lib/tzispa/domain.rb
Constant Summary collapse
- DEFAULT_DOMAIN_NAME =
:default
- DEFAULT_DOMAINS_ROOT =
:apps
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #include(cmod) ⇒ Object
-
#initialize(name = DEFAULT_DOMAIN_NAME, root = DEFAULT_DOMAINS_ROOT) ⇒ Domain
constructor
A new instance of Domain.
- #load(file) ⇒ Object
- #load_dir(dir = nil) ⇒ Object
- #path ⇒ Object
- #require(file) ⇒ Object
- #require_dir(dir = nil) ⇒ Object
Constructor Details
#initialize(name = DEFAULT_DOMAIN_NAME, root = DEFAULT_DOMAINS_ROOT) ⇒ Domain
Returns a new instance of Domain.
16 17 18 19 |
# File 'lib/tzispa/domain.rb', line 16 def initialize(name=DEFAULT_DOMAIN_NAME, root=DEFAULT_DOMAINS_ROOT) @name = name @root = root end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/tzispa/domain.rb', line 10 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/tzispa/domain.rb', line 10 def root @root end |
Class Method Details
.load(domain, file) ⇒ Object
57 58 59 |
# File 'lib/tzispa/domain.rb', line 57 def self.load(domain, file) self.new(name: domain).load(file) end |
.require(domain, file) ⇒ Object
53 54 55 |
# File 'lib/tzispa/domain.rb', line 53 def self.require(domain, file) self.new(name: domain).require(file) end |
Instance Method Details
#include(cmod) ⇒ Object
49 50 51 |
# File 'lib/tzispa/domain.rb', line 49 def include(cmod) name.to_s.capitalize.constantize.include cmod end |
#load(file) ⇒ Object
29 30 31 |
# File 'lib/tzispa/domain.rb', line 29 def load(file) Kernel.load "./#{path}/#{file}.rb" end |
#load_dir(dir = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/tzispa/domain.rb', line 41 def load_dir(dir = nil) rqpath = dir ? "/#{path}/#{dir}" : "/#{path}" Dir[".#{rqpath}/*.rb"].each { |file| name = file.split('/').last Kernel.load ".#{rqpath}/#{name}" } end |
#path ⇒ Object
21 22 23 |
# File 'lib/tzispa/domain.rb', line 21 def path "#{root.to_s.downcase}/#{name.to_s.downcase}".freeze end |
#require(file) ⇒ Object
25 26 27 |
# File 'lib/tzispa/domain.rb', line 25 def require(file) Kernel.require "./#{path}/#{file}" end |
#require_dir(dir = nil) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/tzispa/domain.rb', line 33 def require_dir(dir = nil) rqpath = dir ? "/#{path}/#{dir}" : "/#{path}" Dir[".#{rqpath}/*.rb"].each { |file| name = file.split('/').last.split('.').first Kernel.require ".#{rqpath}/#{name}" } end |