flexserializer 1.0.5 → 1.0.6

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: '0847895f8c2252a5b02ab307c7e70a6d276406ee'
4
- data.tar.gz: 1e4bf76e2daaf9307a3e03124e4bd38fe1ccc3ab
3
+ metadata.gz: 2af5104b81744b9e96b10b97df9b9a1ab6b56d2c
4
+ data.tar.gz: 86ceddcf5f9d165b1fe46fbe5900dd451da215e0
5
5
  SHA512:
6
- metadata.gz: 0a26da36ae42c71f18b63e10640a514f2c5b5d87ca55a801d895f9f8db7a58ac48d384f8dfa539b4af514d6230bb4188781a49ecf0835fb2a35576516c4ef228
7
- data.tar.gz: 954da99a8e7542a0416af467218c6cb5c9abe701e0508c4d501bcbf53c8f020e6853265dfac3c72d66ba83a56f5c0315c04dff756797b5fba2296d64cdf27640
6
+ metadata.gz: 86ca7d1897a1f2e82aa038caf1a384fd6dae0aacc3a7767ee188e349c314695871ba8390e05c948ad45bff418915f59729361a59a790c6463258e237e21195c5
7
+ data.tar.gz: 7e7e104d5a267e6fae7cb8eae6d1c9fc08ed9432d24293efda99af702aad2831ea49010a262d241e291cf838dbfc6dd8a70627bac4ef6c43012708174e78e64d
@@ -1,42 +1,43 @@
1
1
  module Flexserializer
2
2
  class Base < ActiveModel::Serializer
3
3
  class << self
4
- attr_accessor :groups, :data_default_attributes
4
+ attr_accessor :groups, :data_default_attributes
5
+
6
+ def default_attributes(*attrs)
7
+ attrs = attrs.first if attrs.first.class == Array
8
+ self.data_default_attributes = attrs
9
+ end
5
10
 
6
- def default_attributes(*attrs)
7
- attrs = attrs.first if attrs.first.class == Array
8
- self.data_default_attributes = attrs
11
+ def group(group_name, &block)
12
+ self.groups ||= {}
13
+ self.groups[group_name] = block
14
+ end
9
15
  end
10
-
11
- def group(group_name, &block)
12
- self.groups ||= {}
13
- self.groups[group_name] = block
16
+
17
+ def initialize(object, options = {})
18
+ self.class.data_default_attributes ||= []
19
+ define_attributes(options[:group])
20
+ super(object, options)
21
+ end
22
+
23
+ def define_attributes(group)
24
+ clear_data
25
+ define_default_attrs
26
+ return unless self.class.groups.keys.include?(group)
27
+ define_group_attrs(group)
28
+ end
29
+
30
+ def clear_data
31
+ self.class._attributes_data = {}
32
+ end
33
+
34
+ def define_default_attrs
35
+ self.class.data_default_attributes = self.class.data_default_attributes.first if self.class.data_default_attributes.first.class == Array
36
+ self.class.data_default_attributes.each { |attr| self.class.attribute(attr) }
37
+ end
38
+
39
+ def define_group_attrs(group)
40
+ self.class.groups[group].call
14
41
  end
15
- end
16
-
17
- def initialize(object, options = {})
18
- self.class.data_default_attributes ||= []
19
- define_attributes(options[:group])
20
- super(object, options)
21
- end
22
-
23
- def define_attributes(group)
24
- clear_data
25
- define_default_attrs
26
- return unless self.class.groups.keys.include?(group)
27
- define_group_attrs(group)
28
- end
29
-
30
- def clear_data
31
- self.class._attributes_data = {}
32
- end
33
-
34
- def define_default_attrs
35
- self.class.data_default_attributes = self.class.data_default_attributes.first if self.class.data_default_attributes.first.class == Array
36
- self.class.data_default_attributes.each { |attr| self.class.attribute(attr) }
37
- end
38
-
39
- def define_group_attrs(group)
40
- self.class.groups[group].call
41
42
  end
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module Flexserializer
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexserializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - woodcrust