module Ki::Model::Restrictions

Public Instance Methods

forbid(*actions) click to toggle source
# File lib/ki/modules/restrictions.rb, line 10
def forbid(*actions)
  generic_restriction :forbidden_actions, actions
end
forbidden_actions() click to toggle source
# File lib/ki/modules/restrictions.rb, line 6
def forbidden_actions
  []
end
required_attributes() click to toggle source
# File lib/ki/modules/restrictions.rb, line 14
def required_attributes
  []
end
requires(*attributes) click to toggle source
# File lib/ki/modules/restrictions.rb, line 18
def requires(*attributes)
  generic_restriction :required_attributes, attributes
end
unique(*attributes) click to toggle source
# File lib/ki/modules/restrictions.rb, line 26
def unique(*attributes)
  generic_restriction :unique_attributes, attributes
end
unique_attributes() click to toggle source
# File lib/ki/modules/restrictions.rb, line 22
def unique_attributes
  []
end

Private Instance Methods

generic_restriction(method_name, attributes) click to toggle source
# File lib/ki/modules/restrictions.rb, line 32
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