Sha256: a3727cd4d216d78691e4a3fac2c085a37e6bdd5f651c05813e52749cfc4445f1

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Abstractor
  module Methods
    module Models
      module AbstractorAbstractionSource
        def self.included(base)
          base.send :include, SoftDelete

          # Associations
          base.send :belongs_to, :abstractor_subject
          base.send :belongs_to, :abstractor_rule_type
          base.send :belongs_to, :abstractor_abstraction_source_type
          base.send :has_many, :abstractor_suggestion_sources
          base.send :has_many, :abstractor_abstractions, :through => :abstractor_suggestion_sources
          base.send :has_many, :abstractor_indirect_sources

          base.send :attr_accessible, :abstractor_subject, :abstractor_subject_id, :deleted_at, :from_method, :custom_method, :abstractor_rule_type, :abstractor_rule_type_id, :abstractor_abstraction_source_type, :abstractor_abstraction_source_type_id
        end

        def normalize_from_method_to_sources(about)
          sources = []
          fm = nil
          fm = about.send(from_method) unless from_method.blank?
          if fm.is_a?(String) || fm.nil?
            sources = [{ source_type: about.class , source_id: about.id , source_method: from_method }]
          else
            sources = fm
          end
          sources
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
abstractor-2.1.2 lib/abstractor/methods/models/abstractor_abstraction_source.rb
abstractor-2.1.01 lib/abstractor/methods/models/abstractor_abstraction_source.rb
abstractor-2.1.0 lib/abstractor/methods/models/abstractor_abstraction_source.rb
abstractor-2.0.1 lib/abstractor/methods/models/abstractor_abstraction_source.rb