chemistry_rails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
module ChemistryRails
|
6
|
+
module ActiveRecord
|
7
|
+
|
8
|
+
def chemical_formula(column)
|
9
|
+
|
10
|
+
validates_format_of column, with: /\A((#{ChemistryRails::ELEMENTS.reject(&:nil?).map{|i| i[:short] }.join('|')})+[0-9]*)+\Z/, message: :chemistry_rails_formula
|
11
|
+
|
12
|
+
class_eval <<-RUBY, __FILE__, __LINE__+1
|
13
|
+
def #{column}
|
14
|
+
ChemistryRails::Formula.new(self.read_attribute(:#{column}))
|
15
|
+
end
|
16
|
+
RUBY
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end # ActiveRecord
|
21
|
+
end # CarrierWave
|
22
|
+
|
23
|
+
ActiveRecord::Base.extend ChemistryRails::ActiveRecord
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chemistry_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -66,6 +66,8 @@ extensions: []
|
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
68
|
- lib/chemistry_rails.rb
|
69
|
+
- lib/chemistry_rails/orm/activerecord.rb
|
70
|
+
- lib/chemistry_rails/locale/en.yml
|
69
71
|
homepage: https://github.com/CHEMIO/chemistry_rails
|
70
72
|
licenses:
|
71
73
|
- MIT
|
@@ -92,4 +94,3 @@ signing_key:
|
|
92
94
|
specification_version: 3
|
93
95
|
summary: Chemistry rails
|
94
96
|
test_files: []
|
95
|
-
has_rdoc:
|