Module: RailsAssist::UseMacro

Defined in:
lib/rails_assist/macro.rb

Instance Method Summary collapse

Instance Method Details

#artifact_assist(type) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/rails_assist/macro.rb', line 44

def artifact_assist type
  class_eval do
    begin
      module_name = "RailsAssist::Artifact::#{type.to_s.camelize}"
      include module_name.constantize
    rescue
      raise ArgumentError, "Unregistered RailsAssist Artifact library: #{type}, #{module_name}"
    end
  end
end

#assist_with(*types) ⇒ Object Also known as: load_helpers, use_helpers



23
24
25
# File 'lib/rails_assist/macro.rb', line 23

def assist_with *types
  types.each{|type| use_helper type}
end

#default_template_lang(lang) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/rails_assist/macro.rb', line 13

def default_template_lang lang
  class_eval do
    begin
      include "RailsAssist::TemplateLanguage::#{lang.to_s.camelize}".constantize
    rescue
      raise ArgumentError, "Unregistered Template Language: #{lang}"
    end
  end
end

#rails_assist(type) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rails_assist/macro.rb', line 29

def rails_assist type
  class_eval do
    begin
      module_name = "RailsAssist::#{type.to_s.camelize}"
      include module_name.constantize
      if [:files, :directory].include? type
        module_name = "RailsAssist::Artifact::#{type.to_s.camelize}"
        include module_name.constantize
      end
    rescue
      raise ArgumentError, "Unregistered RailsAssist library: #{type}, #{module_name}"
    end
  end
end

#use_helper(type) ⇒ Object Also known as: load_helper



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rails_assist/macro.rb', line 55

def use_helper type
  if type == :special
    class_eval do
      include "RailsAssist::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



3
4
5
6
7
8
9
10
11
# File 'lib/rails_assist/macro.rb', line 3

def use_orm orm
  class_eval do
    begin
      include "RailsAssist::Orm::#{orm.to_s.camelize}".constantize
    rescue
      raise ArgumentError, "Unregistered ORM library: #{orm}"
    end
  end
end