Module: Skyline::HasManyReferablesIn::ClassMethods
- Defined in:
- lib/skyline/has_many_referables_in.rb
Instance Method Summary collapse
-
#has_many_referables_in(*fields) ⇒ Object
Make one or more fields/columns have support for referable content in HTML.
Instance Method Details
#has_many_referables_in(*fields) ⇒ Object
Make one or more fields/columns have support for referable content in HTML.
Overwrites the models accessors for the specified fields/columns. It also adds extra options to the reader. The reader accepts two parameters: ‘edit` (Boolean) and an options string which is passed to InlineRef#convert
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/skyline/has_many_referables_in.rb', line 45 def has_many_referables_in(*fields) self.referable_fields ||= [] fields.each do |f| self.referable_fields << f self.class_eval <<-END def #{f}=(body) self.referable_field_bodies[:#{f}] = body end def #{f}_before_typecast self.referable_field_bodies[:#{f}] || self[:#{f}] end def #{f}(edit = false, options={}) options.reverse_merge! :nullify => false ret = self.referable_field_bodies[:#{f}].nil? ? Skyline::InlineRef.convert(self,:#{f},edit,options) : self.referable_field_bodies[:#{f}] end END end end |