config/initializers/wrappers/scopes/default_scopes.rb in eitil-0.3.2 vs config/initializers/wrappers/scopes/default_scopes.rb in eitil-0.3.3

- old
+ new

@@ -29,11 +29,17 @@ class << self private + def self.inherited(subclass) + use_eitil_scopes + super + end + def use_eitil_scopes + return if abstract_class? %i[boolean datetime date integer float].each { |_type| send :"create_eitil_#{_type}_scopes" } end def eitil_scope(_name, _proc) scope _name, _proc unless respond_to? _name @@ -42,35 +48,35 @@ def columns_of_type(data_type) columns_hash.select { |column,v| v.sql_type_metadata.type == data_type } end def create_eitil_boolean_scopes - columns_of_type(:boolean).map do |column, object| + columns_of_type(:boolean)&.map do |column, object| eitil_scope :"#{column}_true", -> { where(column => true) } eitil_scope :"#{column}_false", -> { where(column => [false, nil]) } end end def create_eitil_datetime_scopes - columns_of_type(:datetime).map do |column, object| + columns_of_type(:datetime)&.map do |column, object| SharableDateScopes.call column end end def create_eitil_date_scopes - columns_of_type(:date).map do |column, object| + columns_of_type(:date)&.map do |column, object| SharableDateScopes.call column end end def create_eitil_integer_scopes - columns_of_type(:integer).map do |column, object| + columns_of_type(:integer)&.map do |column, object| SharableNumScopes.call column end end def create_eitil_float_scopes - columns_of_type(:float).map do |column, object| + columns_of_type(:float)&.map do |column, object| SharableNumScopes.call column end end end \ No newline at end of file