Sha256: b4e4e2fd948e0101ed200e9cfc0056b146ad359ce1bc8dc351ff482fbbb4d1af
Contents?: true
Size: 875 Bytes
Versions: 1
Compression:
Stored size: 875 Bytes
Contents
# frozen_string_literal: true module Ki class Model module Restrictions def forbidden_actions [] end def forbid(*actions) generic_restriction :forbidden_actions, actions end def required_attributes [] end def requires(*attributes) generic_restriction :required_attributes, attributes end def unique_attributes [] end def unique(*attributes) generic_restriction :unique_attributes, attributes end private def generic_restriction(method_name, attributes) attributes += send(method_name) if defined? method_name %i[define_method define_singleton_method].each do |definition_means| send definition_means, method_name do attributes.sort.uniq end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ki-0.4.12 | lib/ki/modules/restrictions.rb |