Class: PAUserProxy
- Inherits:
-
Object
- Object
- PAUserProxy
- Defined in:
- lib/pa_proxies/pa_user_proxy.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#supress_errors ⇒ Object
Returns the value of attribute supress_errors.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(p_user, p_proxy = nil, p_supress_errors = true, p_logger = nil) ⇒ PAUserProxy
constructor
A new instance of PAUserProxy.
- #length ⇒ Object
- #method_missing(sym, *args, &block) ⇒ Object
- #to_s(options = {}) ⇒ Object
Constructor Details
#initialize(p_user, p_proxy = nil, p_supress_errors = true, p_logger = nil) ⇒ PAUserProxy
Returns a new instance of PAUserProxy.
8 9 10 11 12 13 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 8 def initialize(p_user, p_proxy = nil, p_supress_errors = true, p_logger = nil) self.user = p_user self.proxy = p_proxy self.supress_errors = p_supress_errors self.logger = p_logger end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 29 def method_missing(sym, *args, &block) begin if args[0].is_a? Hash = args.delete_at(0) end_proxy = self.proxy.method_missing(sym, *args, &block) [:default] = self.user if end_proxy.data.is_a? Array return end_proxy.collect{|proxy| proxy.to_s()} else return end_proxy.to_s() end else proxy = self.proxy.method_missing(sym, *args, &block) if proxy.data.is_a? String if args[1] and args[1].is_a? Hash return proxy.to_s(args[1].merge({:default => self.user})) else return proxy.to_s({:default => self.user}) end else return self.class.new(self.user, proxy, self.supress_errors) end end rescue Exception => e if self.supress_errors self.logger.error "Phrase: #{e}" unless self.logger.nil? return PAErrorProxy.new("") else raise(e) end end end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 6 def logger @logger end |
#proxy ⇒ Object
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 4 def proxy @proxy end |
#supress_errors ⇒ Object
Returns the value of attribute supress_errors.
5 6 7 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 5 def supress_errors @supress_errors end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 3 def user @user end |
Instance Method Details
#[](index) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 74 def [](index) begin proxy = self.proxy[index] if proxy.data.is_a? String return proxy.to_s(:default => @user) else return self.class.new(self.user, proxy, self.supress_errors) end rescue Exception => e if self.supress_errors self.logger.error "Phrase: #{e}" unless self.logger.nil? return PAErrorProxy.new("") else raise(e) end end end |
#length ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 62 def length begin return self.proxy.length rescue Exception => e if self.supress_errors return 0 else raise(e) end end end |
#to_s(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pa_proxies/pa_user_proxy.rb', line 15 def to_s( = {}) begin = {:default => @user}.merge() self.proxy.to_s() rescue Exception => e if self.supress_errors self.logger.error "Phrase: #{e}" unless self.logger.nil? return PAErrorProxy.new("") else raise(e) end end end |