Sha256: e016ce1a0aa1ba89063dc5b9b30eab4ad5c7edc6baed15e604d1a11886966379
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding : utf-8 -*- require 'mdwa/generators' module MDWA module DSL class EntityAttribute attr_accessor :entity, :name, :type, :default, :style ACCEPTED_TYPES = MDWA::Generators::ModelAttribute::STATIC_TYPES def initialize(entity) self.entity = entity self.default = false end def raise_errors_if_invalid! if !valid? raise "Invalid entity attribute: name is blank" if self.name.blank? raise "Invalid entity attribute: '#{name}' - type is blank" if self.type.blank? raise "Invalid entity attribute: '#{name}' - type '#{type}' is invalid" if self.type_invalid? raise "Invalid entity attribute: '#{name}' - entity is nil" if self.entity.blank? end end def valid? !entity.nil? and !name.blank? and !type.blank? and !type_invalid? end def type_invalid? !ACCEPTED_TYPES.include?( self.type.to_sym ) end def default? self.default end def generate "#{name}:#{type}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems