lca 0.2.6 → 0.2.8

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
  SHA256:
3
- metadata.gz: 3d5a7b8821030f1d77f41f6fda374ffa6179bf8f412355380dbabb17618d820f
4
- data.tar.gz: 1a16958b8df53caa76ade2b50ab6e8a3e522267ba16ae03c19da3667a6f13ea9
3
+ metadata.gz: a16c5260b03c32b7338e2afc954b3b7e81cdac0d70281b381572cef31c4e2100
4
+ data.tar.gz: fb743e4d069c4768b3cb75fd8bd38774a5600148078e1d84bd7dc26e6686c351
5
5
  SHA512:
6
- metadata.gz: a16076c63779cd5dd152e6c4a95a0a332274659648155ff69b61b2d9540e72f74a726155eeac7ae71287d634aceeb5227e2f174e7ff6b418ff2e72b2ec7c1704
7
- data.tar.gz: 194fa4db64be6e462c6be6dfc17eeb4acc7e4861778fd6b292830af20ef394e3a82db564a9199bea8f7fee75e884400058809540b3bc161a54bb007f6c1b1811
6
+ metadata.gz: d0cb142ada744da2836415053fd8e5aa246463d2921dea9ad3b0f92aa1a6c88fe5e50fefdae34189ca6cee87a0bd664fdad47447737d364b1f39018518c3c517
7
+ data.tar.gz: 28bfb9f87f16d36ed059db06a4aa91de7d8b3390b2f49c3f69e74519958d093b64fbdfebb753e26fead95f8fe49aec7352742545f17559bed53e652ffe311316
data/README.md CHANGED
@@ -8,6 +8,8 @@ This gem implements a denormalized database model for life-cycle assessment data
8
8
 
9
9
  ## Installation
10
10
 
11
+ This gem is at home within a Rails 6+ console-only, API or full fledged application on top of a Postgres database.
12
+
11
13
  Add this line to your application's Gemfile:
12
14
 
13
15
  ```ruby
@@ -12,12 +12,7 @@ class Lca::Impact < Lca::Model
12
12
  before_update :snapshot!
13
13
 
14
14
 
15
- def snapshot!
16
- return ::Lca::ImpactSnapshot.create(
17
- self.attributes
18
- .deep_symbolize_keys
19
- .slice(:impact_amount, :impact_amount_unit, :impact_factor, :impact_precision, :owner_id, :owner_type)
20
- .merge( impact_id: id )
21
- )
15
+ def take_snapshot!
16
+ return ::Lca::ImpactSnapshot.take! self
22
17
  end # .snapshot!
23
18
  end
@@ -16,6 +16,8 @@ class Lca::ImpactSnapshot < ActiveRecord::Base
16
16
  validates_presence_of :impact_factor
17
17
  validates_presence_of :impact_precision
18
18
 
19
+
20
+
19
21
  # pull data from owner's partition
20
22
  def self.owned_by(owner_id)
21
23
  return self if !owner_id.is_a? Integer
@@ -41,4 +43,13 @@ class Lca::ImpactSnapshot < ActiveRecord::Base
41
43
  model_class
42
44
  end # owned_by
43
45
 
46
+
47
+ def self.take!(impact)
48
+ return create(
49
+ impact.attributes
50
+ .deep_symbolize_keys
51
+ .slice(:impact_amount, :impact_amount_previous, :impact_amount_unit, :impact_factor, :impact_precision, :owner_id, :owner_type)
52
+ .merge( impact_id: impact.id )
53
+ )
54
+ end # .take!
44
55
  end
data/lib/lca/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lca
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick @ Earthster