DSL configuration in activerecord model in Rails 3
I want to generate reports for some database data. I store report settings in a database using activerecord models, but I don't want that, I want to write something like
class Department < ActiveRecord::Base
...
report do
name "Total Sales by Departments"
method :name
report_field do
name "Total Sales"
action :sum
relation "Sales"
method :spent
end
report_field do
name "Average Sales"
action :avg
relation "Sales"
method :spent
end
end
end
Can someone please tell me how this can be done and what should I read, maybe some examples of other things similar to my problem?
+3
source to share