Class: CycloneLariat::Repo::ActiveRecord::Versions
- Inherits:
-
Object
- Object
- CycloneLariat::Repo::ActiveRecord::Versions
- Defined in:
- lib/cyclone_lariat/repo/active_record/versions.rb
Instance Attribute Summary collapse
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
Instance Method Summary collapse
- #add(version) ⇒ Object
- #all ⇒ Object
-
#initialize(dataset) ⇒ Versions
constructor
A new instance of Versions.
- #remove(version) ⇒ Object
Constructor Details
#initialize(dataset) ⇒ Versions
Returns a new instance of Versions.
9 10 11 |
# File 'lib/cyclone_lariat/repo/active_record/versions.rb', line 9 def initialize(dataset) @dataset = dataset end |
Instance Attribute Details
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
7 8 9 |
# File 'lib/cyclone_lariat/repo/active_record/versions.rb', line 7 def dataset @dataset end |
Instance Method Details
#add(version) ⇒ Object
13 14 15 16 |
# File 'lib/cyclone_lariat/repo/active_record/versions.rb', line 13 def add(version) dataset.create(version: version) true end |
#all ⇒ Object
22 23 24 |
# File 'lib/cyclone_lariat/repo/active_record/versions.rb', line 22 def all dataset.pluck(:version).map { |version| { version: version } } end |
#remove(version) ⇒ Object
18 19 20 |
# File 'lib/cyclone_lariat/repo/active_record/versions.rb', line 18 def remove(version) dataset.where(version: version).delete_all.positive? end |