Module: Cream::GeneratorHelper::Orm
- Defined in:
- lib/generators/cream/helpers/orm_helper.rb
Instance Method Summary collapse
- #active_record ⇒ Object
- #data_mapper ⇒ Object
- #get_orm(name) ⇒ Object
- #is_active_record?(name) ⇒ Boolean
- #is_data_mapper?(name) ⇒ Boolean
- #is_default_devise_orm? ⇒ Boolean
- #is_mongo_mapper?(name) ⇒ Boolean
- #mongo_mapper ⇒ Object
- #orm ⇒ Object
- #valid_orms ⇒ Object
- #valid_orms_list ⇒ Object
- #validate_orm ⇒ Object
Instance Method Details
#active_record ⇒ Object
24 25 26 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 24 def active_record [:ar, :active_record] end |
#data_mapper ⇒ Object
40 41 42 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 40 def data_mapper [:dm, :data_mapper] end |
#get_orm(name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 52 def get_orm name return :active_record if is_active_record? name return :mongo_mapper if is_mongo_mapper? name return :data_mapper if is_data_mapper? name return :couch_db if name == :couch_db return :mongoid if name == :mongoid raise ArgumentError, "ERROR: Cream does not currently support the orm: #{name}" end |
#is_active_record?(name) ⇒ Boolean
28 29 30 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 28 def is_active_record? name active_record.include? name end |
#is_data_mapper?(name) ⇒ Boolean
44 45 46 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 44 def is_data_mapper? name data_mapper.include? name end |
#is_default_devise_orm? ⇒ Boolean
48 49 50 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 48 def is_default_devise_orm? [:active_record, :mongoid].include? orm end |
#is_mongo_mapper?(name) ⇒ Boolean
36 37 38 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 36 def is_mongo_mapper? name mongo_mapper.include? name end |
#mongo_mapper ⇒ Object
32 33 34 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 32 def mongo_mapper [:mm, :mongo_mapper] end |
#orm ⇒ Object
12 13 14 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 12 def orm @orm ||= get_orm [:orm].to_s.underscore.to_sym end |
#valid_orms ⇒ Object
20 21 22 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 20 def valid_orms active_record + data_mapper + mongo_mapper + [:couch_db, :mongoid] end |
#valid_orms_list ⇒ Object
16 17 18 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 16 def valid_orms_list valid_orms.map(&:to_s).join(', ') end |
#validate_orm ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/generators/cream/helpers/orm_helper.rb', line 4 def validate_orm if !valid_orms.include?(orm) say "ERROR: ORM #{orm} is not currently supported. Please use one of: #{valid_orms_list}", :red return false end true end |