Module: ActiveRecordCompose::DelegateAttribute::ClassMethods
- Defined in:
- lib/active_record_compose/delegate_attribute.rb
Instance Method Summary collapse
-
#delegate_attribute(*attributes, to:, **options) ⇒ Object
Defines the reader and writer for the specified attribute.
Instance Method Details
#delegate_attribute(*attributes, to:, **options) ⇒ Object
Defines the reader and writer for the specified attribute.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/active_record_compose/delegate_attribute.rb', line 47 def delegate_attribute(*attributes, to:, **) delegates = attributes.flat_map do |attribute| reader = attribute.to_s writer = "#{attribute}=" [reader, writer] end __skip__ = begin delegate(*delegates, to:, **) delegated_attributes = (self.delegated_attributes ||= []) attributes.each { delegated_attributes.push(_1.to_s) } end end |