Module: Effective::Resources::Naming
- Included in:
- Effective::Resource
- Defined in:
- app/models/effective/resources/naming.rb
Constant Summary collapse
- SPLIT =
- / or
/\/|::/
Instance Method Summary collapse
-
#class_name ⇒ Object
‘Effective::Post’.
-
#class_path ⇒ Object
‘effective’.
- #human_name ⇒ Object
- #human_plural_name ⇒ Object
- #initialized_name ⇒ Object
-
#name ⇒ Object
‘post’.
-
#namespace ⇒ Object
‘admin/things’.
-
#namespaced_class_name ⇒ Object
‘Admin::Effective::Post’.
-
#namespaces ⇒ Object
[‘admin’, ‘things’].
-
#plural_name ⇒ Object
‘posts’.
Instance Method Details
#class_name ⇒ Object
‘Effective::Post’
18 19 20 |
# File 'app/models/effective/resources/naming.rb', line 18 def class_name # 'Effective::Post' @model_klass ? @model_klass.name : name.classify end |
#class_path ⇒ Object
‘effective’
22 23 24 |
# File 'app/models/effective/resources/naming.rb', line 22 def class_path # 'effective' class_name.split('::')[0...-1].map { |name| name.underscore } * '/' end |
#human_name ⇒ Object
38 39 40 |
# File 'app/models/effective/resources/naming.rb', line 38 def human_name class_name.gsub('::', ' ').underscore.gsub('_', ' ') end |
#human_plural_name ⇒ Object
42 43 44 |
# File 'app/models/effective/resources/naming.rb', line 42 def human_plural_name class_name.pluralize.gsub('::', ' ').underscore.gsub('_', ' ') end |
#initialized_name ⇒ Object
14 15 16 |
# File 'app/models/effective/resources/naming.rb', line 14 def initialized_name @initialized_name end |
#name ⇒ Object
‘post’
6 7 8 |
# File 'app/models/effective/resources/naming.rb', line 6 def name # 'post' @name ||= ((klass.present? ? klass.name : initialized_name).to_s.split(SPLIT).last || '').singularize.underscore end |
#namespace ⇒ Object
‘admin/things’
30 31 32 |
# File 'app/models/effective/resources/naming.rb', line 30 def namespace # 'admin/things' (namespaces.join('/') if namespaces.present?) end |
#namespaced_class_name ⇒ Object
‘Admin::Effective::Post’
26 27 28 |
# File 'app/models/effective/resources/naming.rb', line 26 def namespaced_class_name # 'Admin::Effective::Post' (Array(namespaces).map { |name| name.to_s.classify } + [class_name]) * '::' end |
#namespaces ⇒ Object
- ‘admin’, ‘things’
34 35 36 |
# File 'app/models/effective/resources/naming.rb', line 34 def namespaces # ['admin', 'things'] @namespaces || [] end |
#plural_name ⇒ Object
‘posts’
10 11 12 |
# File 'app/models/effective/resources/naming.rb', line 10 def plural_name # 'posts' name.pluralize end |