Class: A9n::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/a9n/scope.rb

Constant Summary collapse

ROOT_NAMES =
[:configuration, :a9n].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Scope

Returns a new instance of Scope.



7
8
9
# File 'lib/a9n/scope.rb', line 7

def initialize(name)
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/a9n/scope.rb', line 5

def name
  @name
end

Class Method Details

.form_file_path(path) ⇒ Object



19
20
21
# File 'lib/a9n/scope.rb', line 19

def self.form_file_path(path)
  new(File.basename(path.to_s).split('.').first.to_sym)
end

Instance Method Details

#env_key_name(key) ⇒ Object



15
16
17
# File 'lib/a9n/scope.rb', line 15

def env_key_name(key)
  (root? ? key : "#{name}_#{key}").upcase
end

#root?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/a9n/scope.rb', line 11

def root?
  ROOT_NAMES.include?(name)
end