Sha256: 59adbc58dad0ccaf0675cb9fb3364a1617df92249e49ab489949cbe4429ff93a
Contents?: true
Size: 831 Bytes
Versions: 7
Compression:
Stored size: 831 Bytes
Contents
require 'generators/common' module Batman module Generators class ModelGenerator < ::Rails::Generators::NamedBase include Common requires_app_name desc "This generator creates a Batman model" argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" def create_batman_model with_app_name do template "batman/model.coffee", "#{app_path}/models/#{singular_table_name.downcase}.js.coffee" end end protected def render_attribute(attribute) type = case attribute.type.to_s when 'date', 'datetime' "Batman.Encoders.railsDate" when 'string', 'integer', 'float', 'decimal', 'boolean', 'text' end ["'#{attribute.name}'", type].compact.join(', ') end end end end
Version data entries
7 entries across 7 versions & 1 rubygems