Florian Gross
9/28/2004 8:24:00 PM
Kevin McConnell wrote:
> In other words, say I have something like this:
>
> class AddressDataSource < DataSourceBase
> field :name, "customer_name"
> field :address, "cust_addr"
> end
>
> ...is there any cunning trickery that would allow me to do this:
>
> datasource AddressDataSource
> field :name, "customer_name"
> field :address, "cust_addr"
> end
You can have this:
datasource(:AddressDataSource) do
field :name, "customer_name"
field :address, "cust_addr"
end
With this:
def datasource(name, &block)
Object.const_set(name, Class.new(DataSourceBase, &block))
end
> Cheers,
> Kevin
Regards,
Florian Gross