Sha256: f0bbc64a3dbd7f949f90e4fdf67b61867c9fd905b59db3a46da9845035e59243
Contents?: true
Size: 596 Bytes
Versions: 2
Compression:
Stored size: 596 Bytes
Contents
module FlexibleEnum class ScopeConfigurator < AbstractConfigurator def apply configurator = self elements.each do |element_name, element_config| add_class_method(scope_name(element_name)) do unscope(:where => configurator.attribute_name).where(configurator.attribute_name => element_config[:value]) end end end private def scope_name(option) if feature_module == module_for_elements option else "#{module_for_elements.to_s.split('::').last.underscore.singularize}_#{option}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flexible_enum-0.3.0 | lib/flexible_enum/scope_configurator.rb |
flexible_enum-0.2.2 | lib/flexible_enum/scope_configurator.rb |