Module: ScopeHelpers
- Included in:
- Ingoweiss::ScaffoldControllerGenerator, Ingoweiss::ScaffoldGenerator, Ingoweiss::ScaffoldViewsGenerator
- Defined in:
- lib/generators/ingoweiss/helpers/scope_helpers.rb
Instance Method Summary collapse
-
#instance_variable_scope(variable = nil) ⇒ Object
Example: ‘@post, @comment, approval’.
- #scope ⇒ Object
-
#scope_prefix ⇒ Object
Example: ‘post_comment_’ for post_comment_approval_path.
- #scoped? ⇒ Boolean
-
#scoped_controller_class_name ⇒ Object
Examples: ‘PostComments’, ‘PostCommentApproval’.
-
#scoped_controller_plural_name ⇒ Object
Examples: ‘post_comments’, ‘post_comment_approval’.
- #singleton? ⇒ Boolean
- #unscoped? ⇒ Boolean
Instance Method Details
#instance_variable_scope(variable = nil) ⇒ Object
Example: ‘@post, @comment, approval’
30 31 32 33 34 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 30 def instance_variable_scope(variable=nil) instance_variables = scope.collect{|s| '@' + s.singularize} instance_variables << variable if variable instance_variables.join(', ') end |
#scope ⇒ Object
3 4 5 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 3 def scope [:scope] end |
#scope_prefix ⇒ Object
Example: ‘post_comment_’ for post_comment_approval_path
20 21 22 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 20 def scope_prefix scope.collect{|s| s.singularize + '_'}.join end |
#scoped? ⇒ Boolean
7 8 9 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 7 def scoped? scope.any? end |
#scoped_controller_class_name ⇒ Object
Examples: ‘PostComments’, ‘PostCommentApproval’
37 38 39 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 37 def scoped_controller_class_name scoped_controller_plural_name.camelize end |
#scoped_controller_plural_name ⇒ Object
Examples: ‘post_comments’, ‘post_comment_approval’
25 26 27 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 25 def scoped_controller_plural_name scope_prefix + ([:singleton] ? singular_name : plural_name) end |
#singleton? ⇒ Boolean
15 16 17 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 15 def singleton? [:singleton] end |
#unscoped? ⇒ Boolean
11 12 13 |
# File 'lib/generators/ingoweiss/helpers/scope_helpers.rb', line 11 def unscoped? !scoped? end |