Module: Cream::GeneratorHelper::Args

Defined in:
lib/generators/cream/helpers/args_helper.rb

Instance Method Summary collapse

Instance Method Details

#active_record?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/generators/cream/helpers/args_helper.rb', line 54

def active_record? 
  active_record.include? orm
end

#admin_classObject



96
97
98
# File 'lib/generators/cream/helpers/args_helper.rb', line 96

def admin_class
  options[:admin_class] || 'Admin'
end

#document_store?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


34
35
36
# File 'lib/generators/cream/helpers/args_helper.rb', line 34

def gems?
  options[:gems]        
end

#guest_user?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/generators/cream/helpers/args_helper.rb', line 80

def guest_user?
  options[:guest_user]
end

#has_user_model?Boolean

Returns:

  • (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

#logfileObject



4
5
6
# File 'lib/generators/cream/helpers/args_helper.rb', line 4

def logfile
  options[:logfile]
end

#logging?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/generators/cream/helpers/args_helper.rb', line 42

def logging?
  options[:logging]
end

#logging_on?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/generators/cream/helpers/args_helper.rb', line 46

def logging_on?
  logfile && logging?
end

#mongoid?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/generators/cream/helpers/args_helper.rb', line 58

def mongoid? 
  orm == :mongoid
end

#role_classObject



100
101
102
# File 'lib/generators/cream/helpers/args_helper.rb', line 100

def role_class
  options[:role_class] || 'Role'
end

#rolesObject

def default_user_types?

options[: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
  options[:roles]
end

#roles_listObject

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_ormObject



22
23
24
# File 'lib/generators/cream/helpers/args_helper.rb', line 22

def set_orm
  self.class.use_orm :"#{orm}"
end

#strategyObject



62
63
64
# File 'lib/generators/cream/helpers/args_helper.rb', line 62

def strategy
  options[:strategy]
end

#sym_rolesObject

def admin_user?

options[: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_classObject



92
93
94
# File 'lib/generators/cream/helpers/args_helper.rb', line 92

def user_class
  options[:user_class] || 'User'
end

#user_role_classObject



104
105
106
# File 'lib/generators/cream/helpers/args_helper.rb', line 104

def user_role_class
  options[:user_role_class] || 'UserRole'
end

#user_typesObject



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        
  options[:user_types]
end

#user_types_codeObject



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_listObject



88
89
90
# File 'lib/generators/cream/helpers/args_helper.rb', line 88

def user_types_list
  user_types.map {|ut| "#{ut}"}.join(' ')
end