Sha256: af1d5e507c19de31e98cf955180fca87227665e3ebeb03de4e8056ba1f11c359
Contents?: true
Size: 1.05 KB
Versions: 8
Compression:
Stored size: 1.05 KB
Contents
require 'generators/active_model' module ActiveModel module Generators class ModelGenerator < Base argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" check_class_collision def create_model_file template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") end def read_properties? attributes.any?{|attr| attr.type == :read } end def read_properties attributes.select{|attr| attr.type == :read}.map{|attr| ":#{attr.name}" }.join(",") end def write_properties? attributes.any?{|attr| attr.type == :write } end def write_properties attributes.select{|attr| attr.type == :write }.map{|attr| ":#{attr.name}" }.join(",") end def accessor_properties? attributes.any?{|attr| attr.type == :all } end def accessor_properties attributes.select{|attr| attr.type == :all }.map{|attr| ":#{attr.name}" }.join(",") end hook_for :test_framework end end end
Version data entries
8 entries across 8 versions & 1 rubygems