Module: Xeroizer::Record::ApplicationHelper
- Included in:
- GenericApplication
- Defined in:
- lib/xeroizer/record/application_helper.rb
Instance Method Summary collapse
-
#record(record_type) ⇒ BaseModel
Factory for new BaseModel instances with the class name ‘record_type`.
- #report(report_type) ⇒ Object
Instance Method Details
#record(record_type) ⇒ BaseModel
Factory for new BaseModel instances with the class name ‘record_type`. Only creates the instance if one doesn’t already exist.
10 11 12 13 14 15 16 17 18 |
# File 'lib/xeroizer/record/application_helper.rb', line 10 def record(record_type) define_method record_type do var_name = "@#{record_type}_cache".to_sym unless instance_variable_defined?(var_name) instance_variable_set(var_name, Xeroizer::Record.const_get("#{record_type}Model".to_sym).new(self, record_type.to_s)) end instance_variable_get(var_name) end end |
#report(report_type) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/xeroizer/record/application_helper.rb', line 20 def report(report_type) define_method report_type do var_name = "@#{report_type}_cache".to_sym unless instance_variable_defined?(var_name) instance_variable_set(var_name, Xeroizer::Report::Factory.new(self, report_type.to_s)) end instance_variable_get(var_name) end end |