module EasyCms::Generators::ResourceHelpers

Private Instance Methods

build_path(template_path) click to toggle source
# File lib/generators/resource_helpers.rb, line 5
def build_path(template_path)
  File.join(File.dirname(__FILE__), template_path)
end
get_model_attributes(name_capitalize_model) click to toggle source
# File lib/generators/resource_helpers.rb, line 15
def get_model_attributes(name_capitalize_model)
  eval("
    begin
      #{name_capitalize_model}.columns.inject([]) do |rtn, model|
        unless ['id', 'created_at', 'updated_at'].include?(model.name)
          rtn << { :name => model.name, :type => model.type }
        end
        rtn
      end
    rescue NameError => e
      return []
    end
  ")
end
read_file(path) click to toggle source
# File lib/generators/resource_helpers.rb, line 9
def read_file(path)
  b = binding
  content = ERB.new(File.read(path)).result b
  content
end