Module: Nayati::NameBasedConstantable
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_name ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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 |