lib/katapult/elements/attribute.rb in katapult-0.4.1 vs lib/katapult/elements/attribute.rb in katapult-0.5.0

- old
+ new

@@ -30,9 +30,25 @@ def has_defaults? !default.nil? and not [flag?, assignable_values].any? end + def renderable? + %i[plain_json json password].exclude? type + end + + def editable? + %i[plain_json json].exclude? type + end + + def required? + if assignable_values.present? + default.blank? && allow_blank.blank? + else + false + end + end + def for_migration db_type = case type when :email, :url, :password then 'string' when :flag then 'boolean' when :money then 'decimal{10,2}' # {precision,scale} = total digits, decimal places