Class: Joey::Page

Inherits:
Profile show all
Defined in:
lib/joey/page.rb

Instance Attribute Summary

Attributes inherited from Model

#client, #errors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Profile

#to_s

Methods inherited from Model

define_properties, find, get_all, has_association, hash_populating_accessor, hash_populating_association, #initialize

Constructor Details

This class inherits a constructor from Joey::Model

Class Method Details

.recognize?(hash) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/joey/page.rb', line 15

def self.recognize?(hash)
  hash.has_key?("category")
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/joey/page.rb', line 25

def valid?
  self.validate
  puts self.errors.inspect unless self.errors.empty?
  self.errors.empty?
end

#validateObject



19
20
21
22
23
# File 'lib/joey/page.rb', line 19

def validate
  valid = true
  errors << { :message => 'id should not be nil' } if id.nil?
  errors << { :message => "name should be string but is #{name.inspect}" } unless name.is_a?(String)
end