Module: Promiscuous::Publisher::Model::Ephemeral
- Extended by:
- ActiveSupport::Concern
- Includes:
- Base
- Included in:
- Mock
- Defined in:
- lib/promiscuous/publisher/model/ephemeral.rb
Defined Under Namespace
Modules: ClassMethods, PromiscuousMethodsEphemeral
Classes: PromiscuousMethods
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Base
#promiscuous, #valid?
Instance Attribute Details
#destroyed ⇒ Object
Returns the value of attribute destroyed.
5
6
7
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 5
def destroyed
@destroyed
end
|
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 5
def id
@id
end
|
#new_record ⇒ Object
Returns the value of attribute new_record.
5
6
7
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 5
def new_record
@new_record
end
|
Instance Method Details
#attributes ⇒ Object
58
59
60
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 58
def attributes
Hash[self.class.published_attrs.map { |attr| [attr, __send__(attr)] }]
end
|
#destroy ⇒ Object
53
54
55
56
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 53
def destroy
self.destroyed = true
save
end
|
#initialize(attrs = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 24
def initialize(attrs={})
self.id ||= 'none'
self.new_record = true
self.destroyed = false
attrs.each { |attr, value| __send__("#{attr}=", value) }
end
|
#save ⇒ Object
Also known as:
save!
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 31
def save
operation = :create
operation = :update unless self.new_record
operation = :destroy if self.destroyed
save_operation(operation)
self.new_record = false
true
end
|
#save_operation(operation) ⇒ Object
#update_attributes(attrs) ⇒ Object
Also known as:
update_attributes!
47
48
49
50
|
# File 'lib/promiscuous/publisher/model/ephemeral.rb', line 47
def update_attributes(attrs)
attrs.each { |attr, value| __send__("#{attr}=", value) }
save
end
|