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
391 392 393 394 |
# File 'lib/groovy/model.rb', line 391 def create(key, attributes) obj = new(key, attributes) obj.save ? obj : false end |
#create!(key, attributes) ⇒ Object
396 397 398 |
# File 'lib/groovy/model.rb', line 396 def create!(key, attributes) create(key, attributes) or raise Error, "Invalid" end |
#find(key) ⇒ Object
380 381 382 383 384 |
# File 'lib/groovy/model.rb', line 380 def find(key) if record = table[key.to_s] and record.record_id new_from_record(record) end end |
#new_from_record(record) ⇒ Object
386 387 388 389 |
# File 'lib/groovy/model.rb', line 386 def new_from_record(record) # new(record.attributes, record) new(record._key, nil, record) end |