Module: Cream::GeneratorHelper::Args
- Defined in:
- lib/generators/cream/helpers/args_helper.rb
Instance Method Summary collapse
- #active_record? ⇒ Boolean
- #admin_class ⇒ Object
- #document_store? ⇒ Boolean
- #gems? ⇒ Boolean
- #guest_user? ⇒ Boolean
- #has_user_model? ⇒ Boolean
- #logfile ⇒ Object
- #logging? ⇒ Boolean
- #logging_on? ⇒ Boolean
- #mongoid? ⇒ Boolean
- #role_class ⇒ Object
-
#roles ⇒ Object
def default_user_types? options end.
-
#roles_list ⇒ Object
def admin_user_option admin_user? ? “–admin-user #admin_user” : ” end.
- #set_orm ⇒ Object
- #strategy ⇒ Object
-
#sym_roles ⇒ Object
def admin_user? options end.
- #user_class ⇒ Object
- #user_role_class ⇒ Object
- #user_types ⇒ Object
- #user_types_code ⇒ Object
- #user_types_list ⇒ Object
Instance Method Details
#active_record? ⇒ Boolean
54 55 56 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 54 def active_record? active_record.include? orm end |
#admin_class ⇒ Object
96 97 98 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 96 def admin_class [:admin_class] || 'Admin' end |
#document_store? ⇒ Boolean
50 51 52 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 50 def document_store? [:mongoid, :mongo_mapper, :couch_db].include? orm end |
#gems? ⇒ Boolean
34 35 36 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 34 def gems? [:gems] end |
#guest_user? ⇒ Boolean
80 81 82 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 80 def guest_user? [:guest_user] end |
#has_user_model? ⇒ Boolean
18 19 20 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 18 def has_user_model? model_file?(user_class.as_filename) end |
#logfile ⇒ Object
4 5 6 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 4 def logfile [:logfile] end |
#logging? ⇒ Boolean
42 43 44 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 42 def logging? [:logging] end |
#logging_on? ⇒ Boolean
46 47 48 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 46 def logging_on? logfile && logging? end |
#mongoid? ⇒ Boolean
58 59 60 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 58 def mongoid? orm == :mongoid end |
#role_class ⇒ Object
100 101 102 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 100 def role_class [:role_class] || 'Role' end |
#roles ⇒ Object
def default_user_types?
[:default_user_types]
end
12 13 14 15 16 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 12 def roles # defaults = default_roles? ? ['guest', 'admin'] : [] # (options[:roles] + defaults).flat_uniq [:roles] end |
#roles_list ⇒ Object
def admin_user_option
admin_user? ? "--admin-user #{admin_user}" : ''
end
30 31 32 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 30 def roles_list roles.join(' ') end |
#set_orm ⇒ Object
22 23 24 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 22 def set_orm self.class.use_orm :"#{orm}" end |
#strategy ⇒ Object
62 63 64 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 62 def strategy [:strategy] end |
#sym_roles ⇒ Object
def admin_user?
[:admin_user]
end
76 77 78 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 76 def sym_roles roles.map(&:to_sym) end |
#user_class ⇒ Object
92 93 94 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 92 def user_class [:user_class] || 'User' end |
#user_role_class ⇒ Object
104 105 106 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 104 def user_role_class [:user_role_class] || 'UserRole' end |
#user_types ⇒ Object
66 67 68 69 70 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 66 def user_types # defaults = default_user_types? ? ['admin'] : [] # (options[:user_types] + defaults).flat_uniq [:user_types] end |
#user_types_code ⇒ Object
84 85 86 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 84 def user_types_code user_types.map {|ut| "'#{ut}'"}.join(', ') end |
#user_types_list ⇒ Object
88 89 90 |
# File 'lib/generators/cream/helpers/args_helper.rb', line 88 def user_types_list user_types.map {|ut| "#{ut}"}.join(' ') end |