class ApplicationSeeds::Attributes
Public Class Methods
new(attributes)
click to toggle source
Calls superclass method
# File lib/application_seeds/attributes.rb, line 6 def initialize(attributes) super(attributes.with_indifferent_access) end
Public Instance Methods
map_attributes(mapping)
click to toggle source
# File lib/application_seeds/attributes.rb, line 20 def map_attributes(mapping) mapping = mapping.with_indifferent_access mapped = inject({}) do |hash, (k, v)| mapped_key = mapping.fetch(k) { k } hash.merge!(mapped_key => v) end Attributes.new(mapped) end
reject_attributes(*attribute_names)
click to toggle source
# File lib/application_seeds/attributes.rb, line 15 def reject_attributes(*attribute_names) attribute_names.map!(&:to_s) Attributes.new(reject { |k, v| attribute_names.include?(k) }) end
select_attributes(*attribute_names)
click to toggle source
# File lib/application_seeds/attributes.rb, line 10 def select_attributes(*attribute_names) attribute_names.map!(&:to_s) Attributes.new(select { |k, v| attribute_names.include?(k) }) end