priceable 0.0.7 → 0.1.0

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
- SHA1:
3
- metadata.gz: 7ac277c8d1cae06483933583c7dc43660c0f6f67
4
- data.tar.gz: cb1e728439ce8144b164792d30808ff8d8262010
2
+ SHA256:
3
+ metadata.gz: 979cd4c2e5777c08973321b4992da3f369e2a062bd62b0ad31c4d93bbed97dbd
4
+ data.tar.gz: 574a5d231b305de09646a870f86b6caf12cf43b9e4988a38045e22a278a5e48f
5
5
  SHA512:
6
- metadata.gz: 43d2bbf764ea01a1055784517cacb022374ac7410d73f22819e28423c4804ae99e1449f4af9c875a10d7a8d415aaeb21a41b42c1ad2dcf968a276bbc108322e0
7
- data.tar.gz: f4357fd051f66a34e8f70c7ab177c018bf504b37d3739ee00e25aa31ea6263b3d62397b4e01992d89f13f1a7c38d4a1b18522242dca107723bab21804e08a1dd
6
+ metadata.gz: 82fb5b8d593e185c2fc008d944a031accdd71e5284891aa1b21231fe35b03d946cff376d8961330ccbe860b938431363b7e64018664ae793904299a4d731f0cc
7
+ data.tar.gz: 7f2acd04f2f2bbba184c5155f4827aa27d3139511eceaa68ee3cbd992e41f2195fd3afc31751098c78be668a67f4a7a6e99ff9d911b81160edd10bf0805d545a
@@ -1,29 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "priceable/version"
2
4
 
3
5
  module Priceable
4
- SUFFIXES = ["_in_cents", "_in_pennies", "_as_integer"]
6
+ SUFFIXES = ["_in_cents", "_in_pennies", "_as_integer"].freeze
7
+
5
8
  def priceable(*price_fields)
6
9
  price_fields.each do |price_field|
7
- suffix = SUFFIXES.detect { |suffix| self.attribute_method? "#{price_field}#{suffix}".to_sym }
10
+ suffix = SUFFIXES.detect { |suffix| attribute_method? "#{price_field}#{suffix}" }
8
11
  raise ArgumentError, "Unable to find valid database field for `#{price_field}'" unless suffix
12
+
9
13
  define_method price_field do
10
- unless send("#{price_field}#{suffix}".to_sym).nil?
11
- send("#{price_field}#{suffix}".to_sym) / 100.0
14
+ unless send("#{price_field}#{suffix}").nil?
15
+ send("#{price_field}#{suffix}") / 100.0
12
16
  else
13
17
  0.0
14
18
  end
15
19
  end
16
- define_method "#{price_field}=".to_sym do |new_price|
17
- send("#{price_field}#{suffix}=".to_sym, (new_price.to_f * 100).round)
20
+
21
+ define_method "#{price_field}=" do |new_price|
22
+ send("#{price_field}#{suffix}=", (new_price.to_f * 100).round)
18
23
  end
19
24
  end
20
-
21
- unless Rails::VERSION::MAJOR == 4 && !defined?(ProtectedAttributes)
22
- if self._accessible_attributes?
23
- attr_accessible *price_fields
24
- end
25
- end
26
-
27
25
  end
28
26
  end
29
27
 
@@ -1,3 +1,3 @@
1
1
  module Priceable
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Priceable::VERSION
17
17
 
18
+ gem.add_dependency("activerecord", '>= 3.0.0')
19
+
18
20
  gem.add_development_dependency('rails')
19
21
  gem.add_development_dependency('rspec')
20
22
  end
metadata CHANGED
@@ -1,41 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: priceable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Cosgrove
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-16 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - '>='
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '>='
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  description: Super simple way to store prices
@@ -45,8 +59,8 @@ executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
- - .gitignore
49
- - .rspec
62
+ - ".gitignore"
63
+ - ".rspec"
50
64
  - Gemfile
51
65
  - LICENSE
52
66
  - README.md
@@ -122,17 +136,17 @@ require_paths:
122
136
  - lib
123
137
  required_ruby_version: !ruby/object:Gem::Requirement
124
138
  requirements:
125
- - - '>='
139
+ - - ">="
126
140
  - !ruby/object:Gem::Version
127
141
  version: '0'
128
142
  required_rubygems_version: !ruby/object:Gem::Requirement
129
143
  requirements:
130
- - - '>='
144
+ - - ">="
131
145
  - !ruby/object:Gem::Version
132
146
  version: '0'
133
147
  requirements: []
134
148
  rubyforge_project:
135
- rubygems_version: 2.0.3
149
+ rubygems_version: 2.7.3
136
150
  signing_key:
137
151
  specification_version: 4
138
152
  summary: Quit storing prices the stupid way. Get Priceable!