Class: Joey::Album
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
Methods inherited from Model
define_properties, find, get_all, has_association, hash_populating_accessor, hash_populating_association, #initialize, recognize?
Constructor Details
This class inherits a constructor from Joey::Model
Instance Method Details
#valid? ⇒ Boolean
36 37 38 39 40 |
# File 'lib/joey/album.rb', line 36 def valid? self.validate puts self.errors.inspect unless self.errors.empty? self.errors.empty? end |
#validate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/joey/album.rb', line 14 def validate created_time.to_time rescue errors << { :message => 'created_time is not compatible' } updated_time.to_time rescue errors << { :message => 'updated_time is not compatible' } errors << { :message => 'id should not be nil' } if id.nil? errors << { :message => "name is neither string nor nil but is #{name.inspect}" } unless name.is_a?(String) || name.nil? errors << { :message => "description is neither string nor nil but is #{description.inspect}" } unless description.is_a?(String) || description.nil? errors << { :message => "link is not a string but is #{link.inspect}" } unless link.is_a?(String) errors << { :message => "count is neither integer nor nil but is #{count.inspect}" } unless count.is_a?(Integer) || count.nil? errors << { :message => "location is neither string nor nil but is #{location.inspect}" } unless location.is_a?(String) || location.nil? errors << { :message => "from is not a Joey::User or Joey::Page and is #{from.inspect}" } unless from.is_a?(Joey::User) || from.is_a?(Joey::Page) #errors << { :message => "comments is not an array nor nil and is #{comments.inspect}" } unless comments.is_a?(Array) || comments.nil? #if comments.is_a?(Array) && !(comments.collect(&:class).uniq - [Joey::Comment]).empty? #errors << { :message => 'comments is not an array of Joey::Comment' } #end #errors << { :message => "photos is not an array nor nil and is #{photos.inspect}" } unless photos.is_a?(Array) || photos.nil? #if photos.is_a?(Array) && !(photos.collect(&:class).uniq - [Joey::Photo]).empty? #errors << { :message => 'photos is not an array of Joey::Comment' } #end end |