Class: Typero::LabelType
- Defined in:
- lib/typero/type/types/label_type.rb
Constant Summary
Constants inherited from Type
Type::ERRORS, Type::OPTS, Type::OPTS_KEYS
Instance Attribute Summary
Attributes inherited from Type
Instance Method Summary collapse
Methods inherited from Type
allowed_opt?, #db_field, db_schema, #default, error, #get, #initialize, load, opts, #value
Constructor Details
This class inherits a constructor from Typero::Type
Instance Method Details
#db_schema ⇒ Object
15 16 17 18 19 |
# File 'lib/typero/type/types/label_type.rb', line 15 def db_schema [:string, { limit: 30 }] end |
#set ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/typero/type/types/label_type.rb', line 2 def set value do |data| data .to_s .gsub(/\s+/,'-') .gsub(/[^\w\-]/,'') .gsub(/\-+/, '-')[0,30] .downcase end error_for(:unallowed_characters_error) unless value =~ /^[\w\-]+$/ end |