Sha256: fdc2cf141efaab356a951fdb9b657c73ed75b0ff1e9ecbd6f18eb95a1b01657e

Contents?: true

Size: 719 Bytes

Versions: 8

Compression:

Stored size: 719 Bytes

Contents

module Reactor
  module Plans
    class CommonAttribute
      include Prepared

      ALLOWED_PARAMS = %i(callback helpText maxSize minSize
                          title values).freeze

      def initialize
        @params = {}
      end

      def set(key, value)
        @params[key.to_sym] = value
      end

      def migrate!
        raise "#{self.class.name} did not implement migrate!"
      end

      protected

      def prepare_params!(_attribute = nil)
        @params.keys.each { |k| error("unknown parameter: #{k}") unless ALLOWED_PARAMS.include? k }
      end

      def migrate_params!(attribute)
        @params.each { |k, v| attribute.set(k, v) }
        attribute.save!
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
infopark_reactor-1.29.1 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.29.0 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.28.0 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.27.0.rc10 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.27.0.rc9 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.27.0.rc8 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.27.0.rc7 lib/reactor/plans/common_attribute.rb
infopark_reactor-1.27.0.rc4 lib/reactor/plans/common_attribute.rb