class SisRuby::Params
Attributes
fields[W]
The conventional ‘attribute=’ method forms for this class are supported in addition to the methods below, as an alternate way to set values.
filter[W]
The conventional ‘attribute=’ method forms for this class are supported in addition to the methods below, as an alternate way to set values.
limit[W]
The conventional ‘attribute=’ method forms for this class are supported in addition to the methods below, as an alternate way to set values.
offset[W]
The conventional ‘attribute=’ method forms for this class are supported in addition to the methods below, as an alternate way to set values.
sort[W]
The conventional ‘attribute=’ method forms for this class are supported in addition to the methods below, as an alternate way to set values.
Public Class Methods
from_hash(other)
click to toggle source
# File lib/sis_ruby/params.rb, line 76 def self.from_hash(other) instance = self.new instance.limit(other['limit']) if other['limit'] instance.fields(other['fields'].split(',').to_set) if other['fields'] instance.offset(other['offset']) if other['offset'] instance.filter(other['q']) if other['q'] instance.sort(other['sort']) if other['sort'] instance end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/sis_ruby/params.rb, line 113 def <=>(other) self.to_h <=> other.to_h end
==(other)
click to toggle source
# File lib/sis_ruby/params.rb, line 108 def ==(other) other.is_a?(self.class) && other.to_h == self.to_h end
clone()
click to toggle source
# File lib/sis_ruby/params.rb, line 87 def clone other = Params.new other.limit(self.limit) if self.limit other.fields(self.fields.clone) if self.fields other.offset(self.offset) if self.offset other.filter(self.filter.clone) if self.filter other.sort(self.sort) if self.sort other end
fields(*args)
click to toggle source
# File lib/sis_ruby/params.rb, line 12 def fields(*args) if args.none? return @fields elsif args.one? @fields = Array(args.first) else @fields = args end @fields = @fields.to_set # order shouldn't matter, and no dups self end
filter(*args)
click to toggle source
# File lib/sis_ruby/params.rb, line 25 def filter(*args) if args.any? @filter = args.first self else @filter end end
hash()
click to toggle source
# File lib/sis_ruby/params.rb, line 103 def hash to_h.hash end
limit(*args)
click to toggle source
# File lib/sis_ruby/params.rb, line 35 def limit(*args) if args.any? @limit = args.first self else @limit end end
offset(*args)
click to toggle source
# File lib/sis_ruby/params.rb, line 45 def offset(*args) if args.any? @offset = args.first self else @offset end end
sort(*args)
click to toggle source
# File lib/sis_ruby/params.rb, line 55 def sort(*args) if args.any? @sort = args.first self else @sort end end
to_h()
click to toggle source
# File lib/sis_ruby/params.rb, line 98 def to_h to_hash end
to_hash()
click to toggle source
# File lib/sis_ruby/params.rb, line 65 def to_hash h = {} h['limit'] = limit if limit h['offset'] = offset if offset h['fields'] = fields.to_a.join(',') if fields h['q'] = filter if filter h['sort'] = sort if sort h end