Sha256: 092b15ed9c6523b8ef30196035a5a89849d973b3f61edfb5f1831223bfc0d2c9

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

module EasyCms
  module Generators
    module ResourceHelpers
      private
      def build_path(template_path)
        File.join(File.dirname(__FILE__), template_path)
      end

      def read_file(path)
        b = binding
        content = ERB.new(File.read(path)).result b
        content
      end

      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easy_cms-0.1.0 lib/generators/resource_helpers.rb