Sha256: 58841411e463b83e61781e32ffc3d6ca8e9d4ec6640801cbd7fbd2c22814d2c1

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

Contents

module Ki
  class Model
    module Restrictions
      def forbidden_actions
        []
      end

      def forbid *actions
        send :define_method, :forbidden_actions do
          actions
        end

        eigen_class = class << self; self; end
        eigen_class.send(:define_method, :forbidden_actions) do
          actions
        end
      end

      def required_attributes
        []
      end

      def requires *attributes
        send :define_method, :required_attributes do
          attributes
        end

        eigen_class = class << self; self; end
        eigen_class.send(:define_method, :required_attributes) do
          attributes
        end
      end

      def unique_attributes
        []
      end

      def unique *attributes
        send :define_method, :unique_attributes do
          attributes
        end

        eigen_class = class << self; self; end
        eigen_class.send(:define_method, :unique_attributes) do
          attributes
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ki-0.4.4 lib/ki/modules/restrictions.rb
ki-0.4.3 lib/ki/modules/restrictions.rb