Sha256: a07362b099de80ab19149bc2fee0b32961f75fbf554dfa5e69f014f8027d61f0

Contents?: true

Size: 751 Bytes

Versions: 11

Compression:

Stored size: 751 Bytes

Contents

module SimpleService
  class ValidatesCommandsProperlyInherit < Command

    expects :provided_commands

    skip_validation true # prevent infinite loop

    def call
      # valid commands inherit from Command and do not inherit from service
      # reject all valid commands and anything left over is invalid
      invalid_commands = provided_commands.to_a.reject do |command|
        command.ancestors.include?(SimpleService::Command) ||
        command.ancestors.include?(SimpleService::Organizer)
      end

      if invalid_commands.any?
        error_msg = invalid_commands.join(', ') +
          ' - must inherit from SimpleService::Command'
        raise SimpleService::CommandParentClassInvalidError, error_msg
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
simple_service-1.4.1 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.4.0 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.91 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.9 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.8 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.5 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.4 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.3 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.2 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.1 lib/simple_service/commands/validates_commands_properly_inherit.rb
simple_service-1.3.0 lib/simple_service/commands/validates_commands_properly_inherit.rb