lib/gov_kit/resource.rb in govkit-0.2.0 vs lib/gov_kit/resource.rb in govkit-0.3.0

- old
+ new

@@ -1,14 +1,16 @@ module GovKit class Resource include HTTParty format :json - attr_accessor :attributes + attr_reader :attributes + attr_reader :raw_response def initialize(attributes = {}) @attributes = {} + @raw_response = attributes unload(attributes) end class << self def instantiate_record(record) @@ -70,10 +72,10 @@ raise NameError, "Namespace for #{namespace} not found" end end def find_or_create_resource_for(name) - resource_name = name.to_s.gsub(/^_/,'').gsub(/^(\d)/, "n#{$1}").gsub(/\s/, '').camelize + resource_name = name.to_s.gsub(/^[_+]/,'').gsub(/^(\d)/, "n#{$1}").gsub(/\s/, '').camelize if self.class.parents.size > 1 find_resource_in_modules(resource_name, self.class.parents) else self.class.const_get(resource_name) end