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