Sha256: d54991b2c08d0bdf4330693b9f18960a4eab45118f04c4c77e0f8accfc648a6f

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

require 'stingray/control_api'
require 'stingray/control_api/soap_helper_methods'

module Stingray::ControlApi::CatalogRuleMethods
  include Stingray::ControlApi::SoapHelperMethods

  %w(
    delete_rule
    get_rule_details
  ).map(&:to_sym).each do |op|
    define_method(:"_custom_#{op}") do |*names|
      _make_names_soap_request(names, 'Catalog.Rule', op)
    end
  end

  def _custom_add_rule(rule_configs)
    body = _build_many_keyed_string_arrays(rule_configs, :names, :texts)
    _make_soap_request('Catalog.Rule', :add_rule, body)
  end

  def _custom_check_syntax(*rule_texts)
    raise ArgumentError.new('No rules given!') if rule_texts.empty?
    body = _build_string_array(rule_texts, :rule_text)
    _make_soap_request('Catalog.Rule', :check_syntax, body)
  end

  def _custom_set_rule_text(rule_configs)
    body = _build_many_keyed_string_arrays(rule_configs, :names, :text)
    _make_soap_request('Catalog.Rule', :set_rule_text, body)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stingray-exec-0.2.0 lib/stingray/control_api/catalog_rule_methods.rb
stingray-exec-0.1.1 lib/stingray/control_api/catalog_rule_methods.rb
stingray-exec-0.1.0 lib/stingray/control_api/catalog_rule_methods.rb