module SourcedAttributes::ClassMethods
Public Instance Methods
sources_attributes_from(source_name, **opts, &block)
click to toggle source
Configure a new Source
for a model.
# File lib/sourced_attributes/sourced_attributes.rb, line 8 def sources_attributes_from source_name, **opts, &block @sources ||= {} @sources[source_name] ||= Source.create(source_name, opts, self) @sources[source_name].instance_eval(&block) @sources[source_name] end
update_sourced_attributes(source_name=nil)
click to toggle source
Apply all Sources to the model. If `source_name` is specified, only apply changes from that Source
.
# File lib/sourced_attributes/sourced_attributes.rb, line 17 def update_sourced_attributes source_name=nil if source_name @sources[source_name].apply else @sources.values.each(&:apply) end end