diff --git a/.ruby-version b/.ruby-version index 94b04ed..81af5fe 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.2.2 +ruby-2.3 diff --git a/README.md b/README.md index 3551dc0..b96a019 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,17 @@ [![Build Status](https://travis-ci.org/PlugaDotCo/nfe_io-ruby.svg?branch=master)](https://travis-ci.org/PlugaDotCo/nfe_io-ruby) -# Nfe - -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nfe`. To experiment with that code, run `bin/console` for an interactive prompt. - -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby -gem 'nfe' +gem 'nfe-io' ``` And then execute: $ bundle -Or install it yourself as: - - $ gem install nfe - ## Usage TODO: Write usage instructions here diff --git a/lib/nfe/api_resource.rb b/lib/nfe/api_resource.rb index c0a92f3..104f8d6 100644 --- a/lib/nfe/api_resource.rb +++ b/lib/nfe/api_resource.rb @@ -40,7 +40,8 @@ def api_request(url, method, params=nil) rescue RestClient::Exception => e raise e end - JSON.parse(response.to_str) + return { } if response == nil || response.empty? + JSON.parse(response) end def self.included(base) diff --git a/lib/nfe/nfe_object.rb b/lib/nfe/nfe_object.rb index 7282f4a..a4926ec 100644 --- a/lib/nfe/nfe_object.rb +++ b/lib/nfe/nfe_object.rb @@ -83,11 +83,10 @@ def to_hash list.push(obj.respond_to?(:to_hash) ? obj.to_hash : value) end result[key] = list - else if value.respond_to?(:to_hash) - result[key] = value.to_hash - else - result[key] = value - end + elsif value.respond_to?(:to_hash) + result[key] = value.to_hash + else + result[key] = value end result end