Sha256: 46276a2bdac997f5216b357f17754cf2efcfcfb2ba0d5c27928cc1a8128bfcda
Contents?: true
Size: 911 Bytes
Versions: 1
Compression:
Stored size: 911 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.2.3 | lib/vraptor-scaffold/generators/scaffold/attribute.rb |