Module: CompositeContent::ActiveRecord::Mixins

Defined in:
lib/composite_content/active_record.rb

Overview

rubocop:enable Naming/PredicateName, Rails/ReflectionClassName

Class Method Summary collapse

Class Method Details

.class_mixin(name) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/composite_content/active_record.rb', line 35

def class_mixin(name)
  Module.new do
    define_method :"strong_parameters_for_#{name}" do
      reflect_on_association(name).class_name.constantize.strong_parameters
    end
  end
end

.instance_mixin(name) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/composite_content/active_record.rb', line 27

def instance_mixin(name)
  Module.new do
    define_method name do
      super() || send(:"build_#{name}")
    end
  end
end