Skip to content

Instantly share code, notes, and snippets.

@rtirrell
Created June 28, 2010 02:11
Show Gist options
  • Save rtirrell/455356 to your computer and use it in GitHub Desktop.
Save rtirrell/455356 to your computer and use it in GitHub Desktop.
>> cor = Cor.first
~ (0.003168) SELECT `id`, `type`, `meth`, `cor`, `pval`, `pval_adj`, `perm_pval`, `len` FROM `cors` ORDER BY `id`, `type`, `meth` LIMIT 1
=> #<Cor @id="1059" @type=:cid @cor=-0.0339791 @pval=1.82219e-05 @pval_adj=nil @perm_pval=0.001 @meth=:pearson @len=15901>
>> cor.update :pval_adj => 0.001
DataMapper::ImmutableError: Immutable resource cannot be modified
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource/state/immutable.rb:16:in `set'
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/model/property.rb:269:in `pval_adj='
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `__send__'
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `attributes='
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `each'
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `attributes='
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:390:in `update'
from (irb):24
>>
require "dm-core"
require "dm-types"
class Cor
include DataMapper::Resource
def self.default_repository_name
:default
end
property :id, String, :key => true
property :type, Enum[:cid, :cui], :key => true
property :cor, Float
property :pval, Float
property :pval_adj, Float
property :perm_pval, Float
property :meth, Enum[:pearson, :spearman], :key => true
property :len, Integer
def dz_name
if type == :cid
SubsetComparison.get(id.to_i).dz_name
else
Disease.get(id).name
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment