fire-model 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7af5be10accd37f7897f73aaf3c9d361a3ab3750
4
- data.tar.gz: 042a151cfaa0ab58bb224a25878eab3553103c89
3
+ metadata.gz: f7fd0add86121b4fbf5a68566e37c7263fd06aa5
4
+ data.tar.gz: c15777871d1c0bf246e586a09ab03b8fb3d2d4c1
5
5
  SHA512:
6
- metadata.gz: 9755db6aa5104dd42df36d2fb64e7e461c9ae7eb9b023550d19781aee79df88cec60916ec61693f5bba8ebfbdcc1218f0e25fafa696455a11de75cd43fb7fa1b
7
- data.tar.gz: 22d64bd1fb51f4de592c4a35f9f69e65fa11d258a21517dff1deba4cf32dcc7ab105ef9e2f783657117e2d5d455a7b10811573d61e6c14405a6804d9e9a4d20f
6
+ metadata.gz: 94df03e10630d8eca7876f2b321988970e591107ca8e6486cff9c72a310e045a966506d9702361330acc626e0887ef4167edaa2ea010fa246c2a6212c23cd931
7
+ data.tar.gz: 136759d17f0a80f3d96ab9bae63db8d1614ce6c95dfadf411200d5b12b4c0a7aaead321045e00d86f96bb0fa89b492b85f4c054b8606d7b5fa8e4ed8ed0de286
data/Gemfile CHANGED
@@ -5,6 +5,8 @@ source 'http://rubygems.org'
5
5
 
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
+ gem 'tarvit-helpers'
9
+
8
10
  group :development do
9
11
  gem 'shoulda', '>= 0'
10
12
  gem 'rdoc', '~> 3.12'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/fire-model.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: fire-model 0.0.1 ruby lib
5
+ # stub: fire-model 0.0.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "fire-model"
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.specification_version = 4
43
43
 
44
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<tarvit-helpers>, [">= 0"])
45
46
  s.add_development_dependency(%q<shoulda>, [">= 0"])
46
47
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
47
48
  s.add_development_dependency(%q<rspec>, ["~> 3.2"])
@@ -51,6 +52,7 @@ Gem::Specification.new do |s|
51
52
  s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
52
53
  s.add_development_dependency(%q<simplecov>, [">= 0"])
53
54
  else
55
+ s.add_dependency(%q<tarvit-helpers>, [">= 0"])
54
56
  s.add_dependency(%q<shoulda>, [">= 0"])
55
57
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
58
  s.add_dependency(%q<rspec>, ["~> 3.2"])
@@ -61,6 +63,7 @@ Gem::Specification.new do |s|
61
63
  s.add_dependency(%q<simplecov>, [">= 0"])
62
64
  end
63
65
  else
66
+ s.add_dependency(%q<tarvit-helpers>, [">= 0"])
64
67
  s.add_dependency(%q<shoulda>, [">= 0"])
65
68
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
69
  s.add_dependency(%q<rspec>, ["~> 3.2"])
data/lib/fire-model.rb CHANGED
@@ -2,6 +2,7 @@ module Fire
2
2
  require 'connection/response'
3
3
  require 'connection/request'
4
4
  require 'model'
5
+
5
6
  require 'ostruct'
6
7
 
7
8
  def self.setup(options)
data/lib/model.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  module Fire
2
2
  require 'ostruct'
3
3
  require 'active_support'
4
+ require 'tarvit-helpers'
4
5
 
5
6
  class Model < OpenStruct
6
-
7
+ include TarvitHelpers::NonSharedAccessors
7
8
  LEVEL_SEPARATOR = ?/
8
9
 
9
- cattr_accessor :firebase_path
10
- cattr_accessor :global_fire_collection, :global_path_keys
10
+ non_shared_cattr_accessor :fire_collection, :path_keys
11
11
 
12
12
  def initialize(attrs={})
13
13
  data = self.class.prepare_hash(attrs)
@@ -53,7 +53,7 @@ module Fire
53
53
  # Data Methods
54
54
 
55
55
  def path_values
56
- self.class.path_keys.map do |pk|
56
+ self.class.all_path_keys.map do |pk|
57
57
  path_value = send(pk)
58
58
  raise PathValueMissingError.new(pk) if path_value.to_s.empty?
59
59
  self.class.path_value_param(path_value)
@@ -62,14 +62,14 @@ module Fire
62
62
 
63
63
  def custom_data(hash=self.data)
64
64
  res = hash.to_a.select do |(k, v)|
65
- !self.class.path_keys.include?(k)
65
+ !self.class.all_path_keys.include?(k)
66
66
  end
67
67
  self.class.prepare_hash(res)
68
68
  end
69
69
 
70
70
  def path_data(hash=self.data)
71
71
  res = hash.to_a.select do |(k, v)|
72
- self.class.path_keys.include?(k.to_sym)
72
+ self.class.all_path_keys.include?(k.to_sym)
73
73
  end
74
74
  self.class.prepare_hash(res)
75
75
  end
@@ -99,32 +99,29 @@ module Fire
99
99
  # Klass Setters
100
100
 
101
101
  def in_collection(name)
102
- self.global_fire_collection ||= {}
103
- self.global_fire_collection[default_collection_name] = name
102
+ self.fire_collection = name
104
103
  end
105
104
 
106
105
  def has_path_keys(*keys)
107
- self.global_path_keys ||= {}
108
- self.global_path_keys[default_collection_name]=keys
106
+ self.path_keys = keys
109
107
  end
110
108
 
111
109
  # Klass Accessors
112
110
 
113
111
  def collection_name
114
- custom_name = (global_fire_collection && global_fire_collection[default_collection_name])
115
- custom_name || default_collection_name
112
+ self.fire_collection || default_collection_name
116
113
  end
117
114
 
118
115
  def connection
119
116
  Fire::Connection::Request.new
120
117
  end
121
118
 
122
- def path_keys
119
+ def all_path_keys
123
120
  own_path_keys + default_path_keys
124
121
  end
125
122
 
126
123
  def own_path_keys
127
- (self.global_path_keys || { })[default_collection_name] ||= []
124
+ self.path_keys || []
128
125
  end
129
126
 
130
127
  # Record Methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fire-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Tarasenko
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tarvit-helpers
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: shoulda
15
29
  requirement: !ruby/object:Gem::Requirement