lib/twilio-ruby/rest/utils.rb in twilio-ruby-4.7.0 vs lib/twilio-ruby/rest/utils.rb in twilio-ruby-4.8.0.edge

- old
+ new

@@ -17,10 +17,17 @@ string.gsub(/[A-Z][a-z]*/) { |s| "_#{s.downcase}" } end protected + # Freeze the base list path. + # Used on list resources so filters (such as /Local) do not affect the + # instance resource path. + def freeze_path + @frozen_path = @path + end + def resource(*resources) custom_resource_names = { sms: 'SMS', sip: 'SIP' } resources.each do |r| resource = twilify r relative_path = custom_resource_names.fetch(r, resource) @@ -29,10 +36,14 @@ Twilio::REST else Twilio::REST.const_get(@submodule) end resource_class = enclosing_module.const_get resource - instance_variable_set("@#{r}", resource_class.new(path, @client)) + resource_object = resource_class.new(path, @client) + instance_variable_set("@#{r}", resource_object) + if @frozen_path + resource_object.instance_variable_set(:@frozen_path, @frozen_path) + end end self.class.instance_eval { attr_reader *resources } end private