module Micro::Attributes::Features::Options
Constants
- ACCEPT_ACCEPT_STRICT
- ACTIVEMODEL_VALIDATION
- BuildKey
- INIT_INIT_STRICT
- INVALID_NAME
- KEYS
- KEYS_TO_FEATURES
- KEYS_TO_MODULES
- NAMES_TO_KEYS
Public Class Methods
fetch_key(arg)
click to toggle source
# File lib/micro/attributes/features.rb, line 89 def self.fetch_key(arg) if arg.is_a?(Hash) return ACCEPT_STRICT if arg[:accept] == :strict INIT_STRICT if arg[:initialize] == :strict else str = String(arg) name = str == ACTIVEMODEL_VALIDATION ? Name::ACTIVEMODEL_VALIDATIONS : str KEYS_TO_MODULES.key?(name) ? name : NAMES_TO_KEYS[name] end end
fetch_keys(args) { |keys| ... }
click to toggle source
# File lib/micro/attributes/features.rb, line 108 def self.fetch_keys(args) keys = Array(args).dup.map { |name| fetch_key(name) } raise ArgumentError, INVALID_NAME if keys.empty? || !(keys - KEYS).empty? yield(keys) end
fetch_module_by_keys(combination)
click to toggle source
# File lib/micro/attributes/features.rb, line 128 def self.fetch_module_by_keys(combination) key = BuildKey.call(combination) KEYS_TO_MODULES.fetch(key) end
remove_base_if_has_strict(keys)
click to toggle source
# File lib/micro/attributes/features.rb, line 116 def self.remove_base_if_has_strict(keys) keys.delete_if { |key| key == INIT } if keys.include?(INIT_STRICT) keys.delete_if { |key| key == ACCEPT } if keys.include?(ACCEPT_STRICT) end
without_keys(keys_to_exclude)
click to toggle source
# File lib/micro/attributes/features.rb, line 121 def self.without_keys(keys_to_exclude) keys = (KEYS - keys_to_exclude) keys.delete_if { |key| key == INIT || key == INIT_STRICT } if keys_to_exclude.include?(INIT) keys.delete_if { |key| key == ACCEPT || key == ACCEPT_STRICT } if keys_to_exclude.include?(ACCEPT) keys end