katana_resource 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13fe737e54c6eec8768b494347bc898ab0a19f8c
4
- data.tar.gz: e19e589f3574b569a53c8f75b959dff4bcf7bae4
3
+ metadata.gz: bdc2f296693e1bb4303f95ba26738db4bfc9b0f2
4
+ data.tar.gz: 9894801f1b5545f7eab26c5b37f7712ff911c3bd
5
5
  SHA512:
6
- metadata.gz: 1f488768b4ee804de25ddd539c30c6ad7ff08a0427ca401806c6dda481153b8c4396f61350e480b66d86f74d00a9f2891f6d7110beabf16b489cddcb58991f52
7
- data.tar.gz: ef99d4b43abca67bf9fe9bad3ec7a2e3f969e76f6b2943208c1b68e7f1974fb2904753d8b99316bf382164371c6c0f5ab891efaede37afe3fcbc6d6c7899640b
6
+ metadata.gz: cfa5b584240ab00e451cda1407d866ac247bbacfba6bc6bed184d80e55fb4b39a0e966fbfeec11e4ad224614631156b70efff2816bb47b9aa9a0c452813fd266
7
+ data.tar.gz: a443f373250a87e7f48a0872e1dbf010b41b647ee1900402aae1bbdbbd39a9f5d238e3085508c91861f88ad13f4d3e17de64bc75ca685dea1e50f6a21ce12408
@@ -1,4 +1,5 @@
1
1
  class Bicycle < KatanaResource::Base
2
+
2
3
  self.root_url = "http://localhost:3000"
3
4
 
4
5
  end
@@ -121,12 +121,15 @@ module KatanaResource
121
121
  when type_name_for_attribute(name) == "Integer" then value.to_i
122
122
  when type_name_for_attribute(name) == "Float" then value.to_f
123
123
  when type_name_for_attribute(name) == "Boolean" then Boolean.new(value).bool_val
124
+
124
125
  when defined?(type_for_attribute(name))
125
126
 
126
127
  # This will be true if we're decoding the record from disc rather than loading
127
128
  # from server
128
129
  # TODO: Refacator this...
129
130
  if value.is_a?(KatanaResource::Base)
131
+ value.attributes ||= {}
132
+
130
133
  return value
131
134
  end
132
135
  return_val = [value].flatten.map { |atts| type_for_attribute(name).new(atts) }
@@ -28,6 +28,7 @@ module KatanaResource
28
28
  include KatanaResource::UrlEncoding
29
29
 
30
30
  def initialize(attributes = {})
31
+ attributes ||= {}
31
32
  attributes = attributes.with_indifferent_access
32
33
  self.class.resource_attributes.each do |resource_att|
33
34
  next unless attributes[resource_att.name]
@@ -19,17 +19,21 @@ module KatanaResource
19
19
  end
20
20
 
21
21
  def current_path
22
- (App.documents_path + "/#{name}.current").freeze
22
+ @current_path ||= File.join(App.documents_path, "#{name}.current").to_s.freeze
23
23
  end
24
24
 
25
25
  def save_current(value = nil)
26
- self.current = value if value
27
- NSKeyedArchiver.archiveRootObject(current, toFile: current_path)
26
+ if value
27
+ self.current = value
28
+ NSKeyedArchiver.archiveRootObject(current, toFile: current_path)
29
+ else
30
+ clear_current
31
+ end
28
32
  end
29
33
 
30
34
  def clear_current
31
35
  self.current = nil
32
- save_current
36
+ File.delete(current_path) if File.exist?(current_path)
33
37
  end
34
38
 
35
39
  def load_current
@@ -1,3 +1,3 @@
1
1
  module KatanaResource
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katana_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodacious
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-require