array_model 1.0.2 → 1.0.3

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: 5398211d195befaca9cd1b8fca571133eb361ae1
4
- data.tar.gz: b4fd880c2977c6f78bfb88a2292bf1299ee58616
3
+ metadata.gz: f6a326d4c7ab542f6b7d0ba1ec87342b850450fc
4
+ data.tar.gz: 5d1f1795ef9afcf734be5053b232b1ab0e82fbc7
5
5
  SHA512:
6
- metadata.gz: fcffddd54f54064f833007cbf1d0523cf93167906c42dc81b31d4220774629e7e0111ea4d04f8f36bade06da2c5ac19cfd693f5bccdd99e5242c2355a426dc0d
7
- data.tar.gz: 1c296642ad79726b14bb70bea84d5724cc1b6b3d2a48d4d4ea49d7ec033d4729efd8f3b3d4fc8573453b7c1367a3c457de7d6c24783f73be750d8aa867bf64d2
6
+ metadata.gz: 57dfb8f862d24d0e6b3fa159c67d1b9ac27c726680051260dbd1f904445018532d4449846d8030de07347d533868ff692e8bf9c96930efbd38f76e47663f327f
7
+ data.tar.gz: 0343679998a7654456cab84afe2befba932be8db6dc42d9dab8cecc3c99c126ba81ac531cabef88a53f6bc249022cdd398a73229e468f115851a3214b8f3ce62
@@ -14,23 +14,23 @@ require "array_model/version"
14
14
  #
15
15
  # Example:
16
16
  #
17
- # USERS = [
18
- # { name: 'Nathan', year: 1984 },
19
- # { name: 'Dave', year: 1987 }
20
- # ]
17
+ # USERS = [
18
+ # { name: 'Nathan', year: 1984 },
19
+ # { name: 'Dave', year: 1987 }
20
+ # ]
21
21
  #
22
- # class User < ArrayModel
23
- # model_data USERS
24
- # attr_model_reader :name
25
- # attr_model_reader :year
22
+ # class User < ArrayModel
23
+ # model_data USERS
24
+ # attr_model_reader :name
25
+ # attr_model_reader :year
26
26
  #
27
- # def age
28
- # Time.now.year - year
29
- # end
30
- # end
27
+ # def age
28
+ # Time.now.year - year
29
+ # end
30
+ # end
31
31
  #
32
- # User[0].age # => 32
33
- # User[1].name # => "Dave"
32
+ # User[0].age # => 32
33
+ # User[1].name # => "Dave"
34
34
  #
35
35
  class ArrayModel
36
36
  # get the object with the key :k:
@@ -39,7 +39,7 @@ class ArrayModel
39
39
  # any field by using the :primary_key option when calling :model_data:
40
40
  # when the class is defined
41
41
  #
42
- # Users['reednj'] # => #<Users:0x007fe693866808>
42
+ # Users['reednj'] # => #<Users:0x007fe693866808>
43
43
  #
44
44
  def self.[](k)
45
45
  if @data_key.nil?
@@ -70,10 +70,10 @@ class ArrayModel
70
70
  # prefered to accessing the hash directly, but this can be useful
71
71
  # in certain cases
72
72
  #
73
- # u = Users['reednj']
74
- # u.username # => 'reednj'
75
- # u.values(:username) # => 'reednj'
76
- # u[:username] # => 'reednj'
73
+ # u = Users['reednj']
74
+ # u.username # => 'reednj'
75
+ # u.values(:username) # => 'reednj'
76
+ # u[:username] # => 'reednj'
77
77
  #
78
78
  def [](k)
79
79
  values[k]
@@ -82,7 +82,7 @@ class ArrayModel
82
82
  # returns the raw Hash that provides the data for the model
83
83
  # object
84
84
  #
85
- # Users['reednj'].values # => {:username => 'reednj', ...}
85
+ # Users['reednj'].values # => {:username => 'reednj', ...}
86
86
  #
87
87
  def values
88
88
  @item_data
@@ -101,12 +101,12 @@ class ArrayModel
101
101
  # of the key in the hash, if it doesn't have the same name as the
102
102
  # method
103
103
  #
104
- # class Users < ArrayModel
105
- # ...
106
- # attr_model_reader :username
107
- # attr_model_reader :user_id, :key => :userId
108
- # ...
109
- # end
104
+ # class Users < ArrayModel
105
+ # ...
106
+ # attr_model_reader :username
107
+ # attr_model_reader :user_id, :key => :userId
108
+ # ...
109
+ # end
110
110
  #
111
111
  def self.attr_model_reader(name, options = {})
112
112
  define_method name.to_sym do
@@ -118,11 +118,11 @@ class ArrayModel
118
118
  # once. No options can be passed when using this method to add
119
119
  # the readers
120
120
  #
121
- # class Users < ArrayModel
122
- # ...
123
- # attr_model_readers [:username, :user_id]
124
- # ...
125
- # end
121
+ # class Users < ArrayModel
122
+ # ...
123
+ # attr_model_readers [:username, :user_id]
124
+ # ...
125
+ # end
126
126
  #
127
127
  def self.attr_model_readers(keys)
128
128
  keys.each {|k| attr_model_reader k }
@@ -140,11 +140,11 @@ class ArrayModel
140
140
  # in the hash when it is accessed later via the subscript operator. If this option
141
141
  # is ommited then the data will be accessable simply by the array index
142
142
  #
143
- # class Users < ArrayModel
144
- # # USER_LIST is a const containing an array of hashes
145
- # model_data USER_LIST, :primary_key => :username
146
- # ...
147
- # end
143
+ # class Users < ArrayModel
144
+ # # USER_LIST is a const containing an array of hashes
145
+ # model_data USER_LIST, :primary_key => :username
146
+ # ...
147
+ # end
148
148
  #
149
149
  def self.model_data(data, options = nil)
150
150
  options ||= {}
@@ -1,3 +1,3 @@
1
1
  class ArrayModel
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Reed