Module: Wordpress::ContentItem::InstanceMethods

Defined in:
lib/content_item.rb

Instance Method Summary collapse

Instance Method Details

#creation_date=(value) ⇒ Object

to_struct



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/content_item.rb', line 33

def creation_date=(value)
  case value
  when String
    @creation_date = Date.parse(value)
  when Date
    @creation_date = value
  when nil
    @creation_date = value
  else
    raise ArgumentError, "Date or String expected instead of #{value.class.name}"
  end
end

#initialize(attributes = {}) ⇒ Object



18
19
20
21
22
# File 'lib/content_item.rb', line 18

def initialize(attributes = {})
  super()
  self.images = []
  apply_attributes(attributes)
end

#to_struct(api) ⇒ Object

initialize



24
25
26
27
28
29
30
31
# File 'lib/content_item.rb', line 24

def to_struct(api)
  struct = {}
  self.class::ATTRIBUTE_MATCHES[api].each do |struct_attribute, item_attribute|
    value = self.send(item_attribute)
    struct[struct_attribute] = value if value
  end
  struct
end