Sha256: 7ce9892d21017efa7a9c71d687b5c1afec89b9241f0757cb79134d2010905b36

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

module Reactor
  module Plans
    class CommonAttribute
      include Prepared

      ALLOWED_PARAMS = [:callback, :helpText, :maxSize, :minSize,
        :title, :values]

      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

3 entries across 3 versions & 1 rubygems

Version Path
infopark_reactor_migrations-1.6.1 lib/reactor/plans/common_attribute.rb
infopark_reactor_migrations-1.5.2 lib/reactor/plans/common_attribute.rb
infopark_reactor_migrations-1.5.1 lib/reactor/plans/common_attribute.rb