lib/hello_sign/resource/base_resource.rb in hellosign-ruby-sdk-3.7.5 vs lib/hello_sign/resource/base_resource.rb in hellosign-ruby-sdk-3.7.6

- old
+ new

@@ -1,6 +1,5 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,25 +17,23 @@ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Stores the value of a hash. Use missing_method to create method to access it like an object # # @author [hellosign] - # + class BaseResource attr_reader :data, :raw_data, :warnings, :headers + + # Converts hash data recursively into BaseResource. # - # recursively convert hash data into BaseResource. - # # @param hash [Hash] Data of the resource # @param key [String] (nil) Key of the hash, point to where resource data is. If nil, then the hash itself. # # @return [HelloSign::Resource::BaseResource] a new BaseResource def initialize(hash, key=nil) @@ -56,18 +53,17 @@ end data end end - # - # Magic method, give class dynamic methods based on hash keys. + # Magic method, gives class dynamic methods based on hash keys. # If initialized hash has a key which matches the method name, return value of that key. # Otherwise, return nil. # # @param method [Symbol] Method's name # # @example - # resource = BaseResource.new :email_address => "me@example.com" + # resource = BaseResource.new email_address: "me@example.com" # resource.email_address => "me@example.com" # resource.not_in_hash_keys => nil def method_missing(method) @data.key?(method.to_s) ? @data[method.to_s] : nil end