Module: Groovy::Model::HashTable::ClassMethods
- Defined in:
- lib/groovy/model.rb
Instance Method Summary collapse
- #create(key, attributes) ⇒ Object
- #create!(key, attributes) ⇒ Object
- #find(key) ⇒ Object
- #new_from_record(record) ⇒ Object
Instance Method Details
#create(key, attributes) ⇒ Object
395 396 397 398 |
# File 'lib/groovy/model.rb', line 395 def create(key, attributes) obj = new(key, attributes) obj.save ? obj : false end |
#create!(key, attributes) ⇒ Object
400 401 402 |
# File 'lib/groovy/model.rb', line 400 def create!(key, attributes) create(key, attributes) or raise Error, "Invalid" end |
#find(key) ⇒ Object
384 385 386 387 388 |
# File 'lib/groovy/model.rb', line 384 def find(key) if record = table[key.to_s] and record.record_id new_from_record(record) end end |
#new_from_record(record) ⇒ Object
390 391 392 393 |
# File 'lib/groovy/model.rb', line 390 def new_from_record(record) # new(record.attributes, record) new(record._key, nil, record) end |