Module: AutoSeeding
- Defined in:
- lib/auto-seeding.rb,
lib/auto-seeding/utils.rb,
lib/auto-seeding/seeder.rb,
lib/auto-seeding/source.rb
Defined Under Namespace
Constant Summary collapse
- NAME =
'auto-seeding'.freeze
- INFO =
'Auto seeding component for ActiveRecord'.freeze
- DESC =
'A component to auto generate seed data with ActiveRecord using a set of predefined or custom rules respecting models validations'.freeze
- AUTHORS =
[ [ 'Mattia Roccoberton', '[email protected]', 'http://blocknot.es' ] ].freeze
- DATE =
'2017-09-30'.freeze
- VERSION =
[ 0, 1, 5 ].freeze
Class Method Summary collapse
-
._deep_merge(hash, other_hash, &block) ⇒ Object
From activesupport.
-
._deep_merge!(hash, other_hash, &block) ⇒ Object
From activesupport.
Class Method Details
._deep_merge(hash, other_hash, &block) ⇒ Object
From activesupport
3 4 5 |
# File 'lib/auto-seeding/utils.rb', line 3 def self._deep_merge( hash, other_hash, &block ) _deep_merge!( hash.dup, other_hash, &block ) end |
._deep_merge!(hash, other_hash, &block) ⇒ Object
From activesupport
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/auto-seeding/utils.rb', line 8 def self._deep_merge!( hash, other_hash, &block ) other_hash.each_pair do |current_key, other_value| this_value = hash[current_key] hash[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash) _deep_merge( this_value, other_value, &block ) else if block_given? && key?(current_key) block.call(current_key, this_value, other_value) else other_value end end end hash end |