Class: CycloneLariat::Repo::ActiveRecord::Versions

Inherits:
Object
  • Object
show all
Defined in:
lib/cyclone_lariat/repo/active_record/versions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#datasetObject (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

#allObject



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