class Compostr::CustomFieldValue
Describe a Custom Field Value with optionally an id (corresponding to the WordPress data).
Attributes
id[RW]
key[RW]
value[RW]
Public Class Methods
new(id, key, value)
click to toggle source
# File lib/compostr/custom_field_value.rb, line 6 def initialize id, key, value @id = id @key = key @value = value end
Public Instance Methods
to_hash()
click to toggle source
Convert to hash that is consumable by RubyPress/Wordpress. Important that neither key nor value are present for custom field values that should be deleted in wordpress instance.
# File lib/compostr/custom_field_value.rb, line 15 def to_hash if @id hsh = { id: @id } hsh[:key] = @key if @key hsh[:value] = @value if @value hsh else hsh = {} hsh[:key] = @key if @key hsh[:value] = @value if @value hsh end end