On Dec 22, 8:32 pm, Jason Dixon <[email protected]> wrote: > I'm attempting to define a custom composition for a boolean column but > it's causing an exception. > > class Site < Sequel::Model > many_to_one :users > plugin :composition > composition :enabled?, :mapping=>[:enabled] > ... > end > > NameError - Site is not a valid constant name!: > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/model/inflections.rb:124:in > `constantize' > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/plugins/composition.rb:68:in > `block in composition' > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/plugins/composition.rb:71:in > `call' > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/plugins/composition.rb:71:in > `block in composition' > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/plugins/composition.rb:107:in > `instance_eval' > > /Users/jdixon/.rvm/gems/ruby-1.9.2-p180/gems/sequel-3.29.0/lib/sequel/plugins/composition.rb:107:in > `block (2 levels) in define_composition_accessor' > /Users/jdixon/Projects/vellup/api.rb:95:in `block in <class:API>' > ... > > Am I using this plugin incorrectly?
You should provide a :class option when using :mapping (the RDoc for the composition plugin needs some work). But my guess is you really want to use boolean_readers plugin instead of the composition plugin. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
