Sha256: 9dbcc81d945263fe871dff3e33a0483f3e770f8c43994b51a9a5e4bd2258e680

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module ForemanTemplates
  class Action
    delegate :logger, :to => :Rails

    def self.setting_overrides
      %i(verbose prefix dirname filter repo negate branch)
    end

    def method_missing(method, *args, &block)
      if self.class.setting_overrides.include?(method)
        instance_variable_get("@#{method}")
      else
        super
      end
    end

    def respond_to_missing?(method, include_private = false)
      self.class.setting_overrides.include?(method)
    end

    def initialize(args = {})
      @taxonomies = { :organizations => args[:organization_params] || {},
                      :locations => args[:location_params] || {} }
      assign_attributes args
    end

    def git_repo?
      @repo.start_with?('http://', 'https://', 'git://', 'ssh://', 'git+ssh://', 'ssh+git://')
    end

    def get_absolute_repo_path
      File.expand_path(@repo)
    end

    def verify_path!(path)
      raise "Using file-based synchronization, but couldn't find #{path}" unless Dir.exist?(path)
    end

    private

    def assign_attributes(args = {})
      self.class.setting_overrides.each do |attribute|
        instance_variable_set("@#{attribute}", args[attribute.to_sym] || Setting["template_sync_#{attribute}".to_sym])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_templates-6.0.1 app/services/foreman_templates/action.rb