Class: Flavordb::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/flavordb/base.rb

Direct Known Subclasses

Business, Product, ProductCategory

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/flavordb/base.rb', line 3

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/flavordb/base.rb', line 3

def name
  @name
end

#resourceObject (readonly)

Returns the value of attribute resource.



3
4
5
# File 'lib/flavordb/base.rb', line 3

def resource
  @resource
end

Class Method Details

.get_or_create(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flavordb/base.rb', line 6

def get_or_create (data)
  #puts "GET OR CREATE #{data}"
  object_id = data['id']
  #puts "OBJECT ID #{object_id}"
  if object_id.nil?
    nil
  else
    object = object_cache[object_id]
    if object.nil?
      object = self.new data
      object_cache[object_id] = object
    end
    object
  end
end