Module: OpenXml::Docx::PropertyBuilder::ClassMethods

Defined in:
lib/openxml/docx/property_builder.rb

Instance Method Summary collapse

Instance Method Details

#propertiesObject



48
49
50
# File 'lib/openxml/docx/property_builder.rb', line 48

def properties
  @properties ||= {}
end

#properties_tag(*args) ⇒ Object



10
11
12
13
# File 'lib/openxml/docx/property_builder.rb', line 10

def properties_tag(*args)
  @properties_tag = args.first if args.any?
  @properties_tag
end

#property(name, as: nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/openxml/docx/property_builder.rb', line 30

def property(name, as: nil)
  properties[name] = (as || name).to_s

  class_eval "  def \#{name}\n    property_key = \"\#{name}\".to_sym\n    class_name = properties[property_key].split(\"_\").map(&:capitalize).join\n    prop_class = OpenXml::Docx::Properties.const_get class_name\n\n    if instance_variable_get(\"@\#{name}\").nil?\n      instance_variable_set \"@\#{name}\", prop_class.new\n    end\n\n    instance_variable_get \"@\#{name}\"\n  end\n  CODE\nend\n", __FILE__, __LINE__ + 1

#value_property(name, as: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/openxml/docx/property_builder.rb', line 15

def value_property(name, as: nil)
  attr_reader name

  properties[name] = (as || name).to_s

  class_eval "  def \#{name}=(value)\n    property_key = \"\#{name}\".to_sym\n    class_name = properties[property_key].split(\"_\").map(&:capitalize).join\n    prop_class = OpenXml::Docx::Properties.const_get class_name\n    instance_variable_set \"@\#{name}\", prop_class.new(value)\n  end\n  CODE\nend\n", __FILE__, __LINE__ + 1