Sha256: 7debc481fd87a4dc6b4f3a890a6aae385628d70d0445cd4cea922590ac95aff5

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

module ForemanRemoteExecution
  module TemplateExtensions
    extend ActiveSupport::Concern

    included do
      # autosave => true is required so the changes of inputs are saved even if template was not changed
      has_many :template_inputs, :dependent => :destroy, :foreign_key => 'template_id', :autosave => true
      has_many :foreign_input_sets, :dependent => :destroy, :foreign_key => 'template_id', :autosave => true

      def template_inputs_with_foreign(templates_stack = [])
        self.template_inputs.to_a + foreign_input_sets.map { |set| set.inputs(templates_stack) }.flatten
      end
      accepts_nested_attributes_for :template_inputs, :allow_destroy => true
      accepts_nested_attributes_for :foreign_input_sets, :allow_destroy => true
      attr_accessible :template_inputs_attributes, :foreign_input_sets_attributes
    end

    # create or overwrite instance methods...
    # def instance_method_name
    # end

    # module ClassMethods
    #   # create or overwrite class methods...
    #   def class_method_name
    #   end
    # end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_remote_execution-1.0.0 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.3.2 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.3.1 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.3.0 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.2.3 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.2.2 app/models/concerns/foreman_remote_execution/template_extensions.rb
foreman_remote_execution-0.2.1 app/models/concerns/foreman_remote_execution/template_extensions.rb