Module: Nayati::NameBasedConstantable

Included in:
Operation, Workflow
Defined in:
app/models/nayati/name_based_constantable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.name_as_constant(name) ⇒ Object



18
19
20
# File 'app/models/nayati/name_based_constantable.rb', line 18

def self.name_as_constant(name)
  name.to_s.split(' ').join('_').camelcase
end

.name_as_namespace(name) ⇒ Object



22
23
24
# File 'app/models/nayati/name_based_constantable.rb', line 22

def self.name_as_namespace(name)
  name.to_s.downcase.split(' ').join('_')
end

.underscored_name(name) ⇒ Object



26
27
28
# File 'app/models/nayati/name_based_constantable.rb', line 26

def self.underscored_name(name)
  name.to_s.underscore.split(' ').join('_')
end

Instance Method Details

#camelcased_nameObject



3
4
5
6
# File 'app/models/nayati/name_based_constantable.rb', line 3

def camelcased_name
  return "" if name.nil?
  Nayati::NameBasedConstantable.name_as_constant(self.name)
end

#namespaced_nameObject



8
9
10
11
# File 'app/models/nayati/name_based_constantable.rb', line 8

def namespaced_name
  return "" if name.nil?
  Nayati::NameBasedConstantable.name_as_namespace(self.name)
end

#underscored_nameObject



13
14
15
16
# File 'app/models/nayati/name_based_constantable.rb', line 13

def underscored_name
  return "" if name.nil?
  Nayati::NameBasedConstantable.underscored_name(name)
end