Sha256: cbf7d0553ecc8eb416cbc578efe56b20adee3f8db26cdc3e193e872e8596abd1
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
class Attribute attr_accessor :name, :type def initialize(name, type) @name = name.underscore.camelize(:lower) @type = type.downcase validate end def html_input input = "text" input = "checkbox" if boolean? input = "textarea" if type.eql?("text") input end def html_label @name.underscore.humanize end def java_type java = type.capitalize java = "boolean" if boolean? java = "String" if type.eql?("text") java end def self.valid_types %w(boolean double float short integer long string text) end def boolean? type.eql? "boolean" end def getter_prefix return "is" if boolean? "get" end def validate unless Attribute.valid_types.include?(@type) puts "Attribute #{@type} is not supported. The supported attributes types are: #{Attribute.valid_types.join(", ")}" Kernel::exit end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vraptor-scaffold-1.3.0.rc | lib/vraptor-scaffold/generators/scaffold/attribute.rb |