Module: Rails3::Assist::UseMacro
- Defined in:
- lib/rails3_artifactor/macro.rb
Instance Method Summary collapse
- #artifact_assist(type) ⇒ Object
- #assist_with(*types) ⇒ Object (also: #load_helpers, #use_helpers)
- #rails_assist(type) ⇒ Object
- #use_helper(type) ⇒ Object (also: #load_helper)
- #use_orm(orm) ⇒ Object
Instance Method Details
#artifact_assist(type) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rails3_artifactor/macro.rb', line 36 def artifact_assist type class_eval do begin module_name = "Rails3::Assist::Artifact::#{type.to_s.camelize}" include module_name.constantize rescue raise ArgumentError, "Unregistered Rails3 Artifact assist library: #{type}, #{module_name}" end end end |
#assist_with(*types) ⇒ Object Also known as: load_helpers, use_helpers
15 16 17 |
# File 'lib/rails3_artifactor/macro.rb', line 15 def assist_with *types types.each{|type| use_helper type} end |
#rails_assist(type) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails3_artifactor/macro.rb', line 21 def rails_assist type class_eval do begin module_name = "Rails3::Assist::#{type.to_s.camelize}" include module_name.constantize if [:files, :directory].include? type module_name = "Rails3::Assist::Artifact::#{type.to_s.camelize}" include module_name.constantize end rescue raise ArgumentError, "Unregistered Rails3 assist library: #{type}, #{module_name}" end end end |
#use_helper(type) ⇒ Object Also known as: load_helper
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rails3_artifactor/macro.rb', line 47 def use_helper type if type == :special class_eval do include "Rails3::Assist::File::Special".constantize end return end return rails_assist(type) if [:file, :files, :directory, :app].include?(type) artifact_assist(type) end |
#use_orm(orm) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/rails3_artifactor/macro.rb', line 5 def use_orm orm class_eval do begin include "Rails3::Assist::Orm::#{orm.to_s.camelize}".constantize rescue raise ArgumentError, "Unregistered ORM library: #{orm}" end end end |