Module: BaiduApi::LbsCloud::V3::RequestBase::ClassMethods

Defined in:
lib/baidu_api/lbs_cloud/v3/request_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controllerObject



27
28
29
# File 'lib/baidu_api/lbs_cloud/v3/request_base.rb', line 27

def controller
  @controller
end

#module_nameObject



22
23
24
25
# File 'lib/baidu_api/lbs_cloud/v3/request_base.rb', line 22

def module_name
  fail 'module_name has to be defined' if @module_name.nil?
  @module_name
end

Instance Method Details

#add_raise_methods(*methods) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/baidu_api/lbs_cloud/v3/request_base.rb', line 31

def add_raise_methods(*methods)
  methods.flatten.each do |m|
    class_eval <<-CODE
      def #{m}!(*args)
        ret = #{m}(*args)
        raise BaiduApi::LbsCloud::Exceptions::Failed.new(ret) if ret['status'] != 0
        ret
      end
    CODE
  end
end