Module: Qiita::Team::Services::Hooks::Concerns::Persistable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/qiita/team/services/hooks/concerns/persistable.rb
Instance Method Summary collapse
- #initialize(hash) ⇒ Object
-
#marked_for_destruction? ⇒ Boolean
Returns whether or not this record will be destroyed as part of the parents save transaction.
-
#to_hash ⇒ Hash{String => Object}
Serialize the service object.
Instance Method Details
#initialize(hash) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/qiita/team/services/hooks/concerns/persistable.rb', line 35 def initialize(hash) self.class.service_properties.each do |property| if hash.key?(property.name) public_send("#{property.name}=", hash[property.name]) else public_send("#{property.name}=", property.default) end end end |
#marked_for_destruction? ⇒ Boolean
Note:
Override ActiveRecord::AutosaveAssociation#marked_for_destruction?.
Returns whether or not this record will be destroyed as part of the parents save transaction.
58 59 60 |
# File 'lib/qiita/team/services/hooks/concerns/persistable.rb', line 58 def marked_for_destruction? false end |
#to_hash ⇒ Hash{String => Object}
Serialize the service object.
48 49 50 51 52 |
# File 'lib/qiita/team/services/hooks/concerns/persistable.rb', line 48 def to_hash self.class.service_properties.map(&:name).each_with_object({}) do |name, hash| hash[name] = public_send(name) end end |