Sha256: 349f3fd86f83f49c5acaa0ba32835146b362f4f0110e69c457054f86be9c6693

Contents?: true

Size: 656 Bytes

Versions: 9

Compression:

Stored size: 656 Bytes

Contents

module Scimaenaga
  class ScimCount
    include ActiveModel::Model

    attr_accessor \
      :limit,
      :offset,
      :start_index,
      :total

    def limit
      return 100 if @limit.blank?

      validate_numericality(@limit)
      input = @limit.to_i
      raise if input < 1

      input
    end

    def start_index
      return 1 if @start_index.blank?

      validate_numericality(@start_index)
      input = @start_index.to_i
      return 1 if input < 1

      input
    end

    def offset
      start_index - 1
    end

    private

      def validate_numericality(input)
        raise unless input.match?(/\A\d+\z/)
      end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scimaenaga-1.0.5 app/models/scimaenaga/scim_count.rb
scimaenaga-1.0.4 app/models/scimaenaga/scim_count.rb
scimaenaga-1.0.3 app/models/scimaenaga/scim_count.rb
scimaenaga-1.0.2 app/models/scimaenaga/scim_count.rb
scimaenaga-1.0.1 app/models/scimaenaga/scim_count.rb
scimaenaga-1.0.0 app/models/scimaenaga/scim_count.rb
scimaenaga-0.9.3 app/models/scimaenaga/scim_count.rb
scimaenaga-0.9.2 app/models/scimaenaga/scim_count.rb
scimaenaga-0.9.1 app/models/scimaenaga/scim_count.rb