Module: XMLable::Mixins::ContentStorage

Defined in:
lib/xmlable/mixins/content_storage.rb

Overview

ContentStorage module contains the logic that helps to store XML element

content.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/xmlable/mixins/content_storage.rb', line 8

def self.included(base)
  base.send(:extend, ClassMethods)
end

Instance Method Details

#__contentObject

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.

Get content value

Returns:



55
56
57
# File 'lib/xmlable/mixins/content_storage.rb', line 55

def __content
  @__content
end

#__content=(val) ⇒ 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.

Set content value

Parameters:

Returns:



68
69
70
# File 'lib/xmlable/mixins/content_storage.rb', line 68

def __content=(val)
  __overwrite_content(val)
end

#__content_methodString?

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.

Get content alias method

Returns:

  • (String, nil)


98
99
100
# File 'lib/xmlable/mixins/content_storage.rb', line 98

def __content_method
  self.class.__content_method
end

#__content_methodsArray<String>

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.

Contents methods

Returns:

  • (Array<String>)


109
110
111
112
113
# File 'lib/xmlable/mixins/content_storage.rb', line 109

def __content_methods
  ret = ['__content']
  ret << __content_method.to_s if __content_method
  ret
end

#__empty?Boolean

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.

Is this element?

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/xmlable/mixins/content_storage.rb', line 79

def __empty?
  return false unless super
  __empty(__content)
end

#__objectObject

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.

Get content value

Returns:



44
45
46
# File 'lib/xmlable/mixins/content_storage.rb', line 44

def __object
  __content
end

#__overwrite_content(val) ⇒ 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.

Override XML node content

Parameters:



31
32
33
34
35
# File 'lib/xmlable/mixins/content_storage.rb', line 31

def __overwrite_content(val)
  val = __cast(val)
  @__node.content = __export_to_xml(val)
  @__content = val
end

#__set_content(node) ⇒ 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.

Set XML element content

Parameters:

  • node (Nokogiri::XML::Element)


19
20
21
22
# File 'lib/xmlable/mixins/content_storage.rb', line 19

def __set_content(node)
  val = node.children.select(&:text?).map(&:content).join('').strip
  @__content = __cast(val)
end

#to_sString

Returns:

  • (String)


87
88
89
# File 'lib/xmlable/mixins/content_storage.rb', line 87

def to_s
  __content.to_s
end