Class: Pakyow::Data::Sources::Ephemeral
- Inherits:
-
Base
- Object
- SimpleDelegator
- Base
- Pakyow::Data::Sources::Ephemeral
show all
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/pakyow/data/sources/ephemeral.rb
Constant Summary
collapse
- COMMANDS =
i(set).freeze
Instance Attribute Summary collapse
Attributes inherited from Base
#original_results
Instance Method Summary
collapse
Methods inherited from Base
instance, #modifier?, plural_name, #pp, #query?, singular_name, #source_from_self, source_from_source
Constructor Details
#initialize(type, **qualifications) ⇒ Ephemeral
Returns a new instance of Ephemeral.
22
23
24
25
26
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 22
def initialize(type, **qualifications)
@type = type
@qualifications = { type: @type }.merge(qualifications)
__setobj__([])
end
|
Instance Attribute Details
#qualifications ⇒ Object
Returns the value of attribute qualifications.
15
16
17
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 15
def qualifications
@qualifications
end
|
Returns the value of attribute type.
15
16
17
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 15
def type
@type
end
|
Instance Method Details
#command(maybe_command_name) ⇒ Object
61
62
63
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 61
def command(maybe_command_name)
method(maybe_command_name)
end
|
#command?(maybe_command_name) ⇒ Boolean
57
58
59
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 57
def command?(maybe_command_name)
COMMANDS.include?(maybe_command_name)
end
|
52
53
54
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 52
def one
to_a.first
end
|
#set(results) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 28
def set(results)
tap do
__setobj__(
results.map { |result|
unless result.key?(:id)
result[:id] = SecureRandom.uuid
end
result
}
)
yield self if block_given?
end
end
|
#source_name ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
66
67
68
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 66
def source_name
@type
end
|
48
49
50
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 48
def to_a
Array.ensure(__getobj__)
end
|
44
45
46
|
# File 'lib/pakyow/data/sources/ephemeral.rb', line 44
def to_ary
to_a
end
|