module Cfan122::OperationMethods

Public Class Methods

attrs() click to toggle source
# File lib/cfan122/operation_methods.rb, line 24
def self.attrs
  [:province, :city, :subject, :type, :location, :page]
end

Public Instance Methods

attributes() click to toggle source
# File lib/cfan122/operation_methods.rb, line 10
def attributes
  attrs = self.class.const_defined?('PARAMS') ? (self.class.attrs + self.class::PARAMS) : self.class.attrs
  attrs.map{|key| [key, public_send("#{key}")]}.to_h
end
attributes=(hash) click to toggle source
# File lib/cfan122/operation_methods.rb, line 15
def attributes=(hash)
  hash.each{|key, value| public_send("#{key}=", value) if self.class.method_defined? "#{key}=" }
end
set_default() click to toggle source
# File lib/cfan122/operation_methods.rb, line 32
def set_default
  @province ||= :ln
  @subject ||= 3
  @type ||= 'C1'
  @city ||= '辽B'
  @location ||= '21020103'
  @page ||= 1
end
to_params(options = {}) click to toggle source
# File lib/cfan122/operation_methods.rb, line 19
def to_params options = {}
  options = options.select{|k, v| self.class::PARAMS.include?(k) } if self.class.const_defined?('PARAMS')
  options.map{|k, v| ["#{k}", v] }.to_h
end