active_delegate 0.1.3 → 0.1.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: 5480972eade03dbf9ba6243f90028eb9ad46ffaa
4
- data.tar.gz: 8372d588d8f5b383eba4f727bc56b78e2a533d77
3
+ metadata.gz: 8b25f154bc3bf1b847b20e9b4b410523881d47f1
4
+ data.tar.gz: 99f6ddd155f8d6e52fc72d0de2fab400604366a0
5
5
  SHA512:
6
- metadata.gz: ead37ccef91c33ebb9ad0076894a6fd129331d516ad81cba08995cf984e7ac6ec96106ba9cfca05fa19e10861225cc6a900184c78d39128ec6af4fb8a1ff22c1
7
- data.tar.gz: a1c912a92de34d6f1fdb52d7ac696c43b8d71de8a587b00a6d29e8812c426887607b13e8c00f07939f8b9a4df8d3a9b23c5ad99b141e6250ea80492a334ec632
6
+ metadata.gz: a37d3dc37ab0f5a6bc55ba414179758c470e73cd8dbf95df474e8783f7b262abd2d59b69cb961582de5aad7dd997b84ac46b62549e5f96d76c35dba65959490f
7
+ data.tar.gz: f8fe8f1bcec56fda65430bc519d05d5092c66b46dfa0ecaea64a70f2c17ad7ba66825fee08591e89c4b6c309344a7fbc4f9817fc227e5cbae8ed8e8fa5b2dfdb
@@ -102,13 +102,16 @@ module ActiveDelegate
102
102
  end
103
103
  end
104
104
 
105
+ # Get attribute prefix
106
+ def attribute_prefix
107
+ prefix = @options[:prefix]
108
+ prefix.is_a?(TrueClass) ? @options[:to] : prefix
109
+ end
110
+
105
111
  # Get prefixed attributes
106
112
  def prefix_attributes(attributes)
107
113
  if @options[:prefix].present?
108
- prefix = @options[:prefix]
109
- prefix = @options[:to] if prefix.is_a? TrueClass
110
-
111
- attributes.map { |a| :"#{prefix}_#{a}" }
114
+ attributes.map { |a| :"#{attribute_prefix}_#{a}" }
112
115
  else
113
116
  attributes
114
117
  end
@@ -134,7 +137,7 @@ module ActiveDelegate
134
137
  # Define attribute names and types
135
138
  def define_attribute_names_and_types(attributes)
136
139
  attributes.each do |attrib|
137
- attr_name = attrib.to_s.sub("#{@options[:to]}_", '')
140
+ attr_name = attrib.to_s.sub("#{attribute_prefix}_", '')
138
141
  cast_type = association_class.attribute_types["#{attr_name}"]
139
142
 
140
143
  @model.attribute(attrib, cast_type) unless cast_type.nil?
@@ -1,3 +1,3 @@
1
1
  module ActiveDelegate
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_delegate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli