lib/grumlin/pop.rb in grumlin-0.5.1 vs lib/grumlin/pop.rb in grumlin-0.6.0
- old
+ new
@@ -1,28 +1,17 @@
# frozen_string_literal: true
module Grumlin
module Pop
+ # TODO: share the code?
class << self
- FIRST = { "@type": "g:Pop", "@value": "first" }.freeze
- LAST = { "@type": "g:Pop", "@value": "last" }.freeze
- ALL = { "@type": "g:Pop", "@value": "all" }.freeze
- MIXED = { "@type": "g:Pop", "@value": "mixed" }.freeze
+ %i[first last all mixed].each do |step|
+ define_method step do
+ name = "@#{step}"
+ return instance_variable_get(name) if instance_variable_defined?(name)
- def first
- FIRST
- end
-
- def last
- LAST
- end
-
- def all
- ALL
- end
-
- def mixed
- MIXED
+ instance_variable_set(name, TypedValue.new("Pop", step))
+ end
end
end
end
end