From: "David A. Black" Date: 2004-08-13T20:59:11+09:00 Subject: Re: Relationship between classes Hi -- On Fri, 13 Aug 2004, Luke A. Kanies wrote: > ... > :chown => [ > [:owner, :file], > proc { |object| > Blink::Operation::Chown.new( > :owner => proc { |object| object[:uid] }, > :file => proc { |object| object[:file] } > ) > } > ], > ... > > This stores my three key pieces of information: What the object calls the > operation (so it knows how to execute it on itself later), what attributes > are necessary in order to create an instance of the operation, and how to > actuallly instantiate the operation. > > I am currently storing all of these in a big hash in each object class > definition. > > This seems really inelegant, though, and it causes some weird side effects > in my thinking. > > Is there some better way to store these relationships, without causing > leaking of the object interface into the operation definition? Maybe create some classes to wrap all of this in, so that you would then do something like: obj.add_operation(:chown) do |op| op.attributes = [:owner,:file] op.action = lambda {|object| .... } ... end and so on. That might scale more nicely, and allow you to easily add ways to query and view things as you go. David -- David A. Black dblack@wobblini.net