infopark_reactor 1.26.1 → 1.27.0.rc10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +25 -0
  3. data/.rubocop_todo.yml +363 -0
  4. data/Rakefile +10 -13
  5. data/app/models/rails_connector/abstract_obj.rb +2 -1
  6. data/config/routes.rb +0 -1
  7. data/infopark_reactor.gemspec +16 -15
  8. data/lib/generators/cm/migration/migration_generator.rb +4 -8
  9. data/lib/infopark_reactor.rb +43 -69
  10. data/lib/reactor/already_released.rb +1 -2
  11. data/lib/reactor/attributes.rb +92 -268
  12. data/lib/reactor/attributes/date_serializer.rb +23 -16
  13. data/lib/reactor/attributes/html_serializer.rb +6 -5
  14. data/lib/reactor/attributes/link_list_extender.rb +10 -8
  15. data/lib/reactor/attributes/link_list_from_accessor.rb +2 -1
  16. data/lib/reactor/attributes/link_list_from_attr_values.rb +2 -1
  17. data/lib/reactor/attributes/link_list_serializer.rb +8 -7
  18. data/lib/reactor/attributes_handlers.rb +164 -0
  19. data/lib/reactor/cache/permission.rb +6 -9
  20. data/lib/reactor/cache/user.rb +3 -6
  21. data/lib/reactor/cm/attribute.rb +16 -16
  22. data/lib/reactor/cm/attribute_group.rb +18 -21
  23. data/lib/reactor/cm/blob_too_small_error.rb +2 -2
  24. data/lib/reactor/cm/bridge.rb +6 -9
  25. data/lib/reactor/cm/channel.rb +3 -4
  26. data/lib/reactor/cm/editorial_group.rb +2 -9
  27. data/lib/reactor/cm/group.rb +30 -43
  28. data/lib/reactor/cm/job.rb +23 -25
  29. data/lib/reactor/cm/language.rb +21 -22
  30. data/lib/reactor/cm/link.rb +38 -40
  31. data/lib/reactor/cm/live_group.rb +2 -9
  32. data/lib/reactor/cm/log_entry.rb +22 -21
  33. data/lib/reactor/cm/missing_credentials.rb +3 -2
  34. data/lib/reactor/cm/multi_xml_request.rb +22 -25
  35. data/lib/reactor/cm/obj.rb +159 -154
  36. data/lib/reactor/cm/obj_class.rb +52 -51
  37. data/lib/reactor/cm/object_base.rb +26 -21
  38. data/lib/reactor/cm/permissions.rb +7 -7
  39. data/lib/reactor/cm/user.rb +43 -51
  40. data/lib/reactor/cm/workflow.rb +11 -12
  41. data/lib/reactor/cm/xml_attribute.rb +10 -19
  42. data/lib/reactor/cm/xml_markup.rb +7 -10
  43. data/lib/reactor/cm/xml_multi_request_error.rb +1 -3
  44. data/lib/reactor/cm/xml_request.rb +21 -29
  45. data/lib/reactor/cm/xml_request_error.rb +1 -3
  46. data/lib/reactor/cm/xml_response.rb +8 -16
  47. data/lib/reactor/cm/xml_single_request_error.rb +3 -5
  48. data/lib/reactor/configuration.rb +1 -3
  49. data/lib/reactor/engine.rb +5 -10
  50. data/lib/reactor/legacy.rb +6 -7
  51. data/lib/reactor/link/external.rb +8 -5
  52. data/lib/reactor/link/internal.rb +8 -5
  53. data/lib/reactor/link/temporary_link.rb +16 -17
  54. data/lib/reactor/main.rb +11 -15
  55. data/lib/reactor/migration.rb +52 -53
  56. data/lib/reactor/no_working_version.rb +1 -2
  57. data/lib/reactor/not_permitted.rb +1 -2
  58. data/lib/reactor/permission.rb +36 -38
  59. data/lib/reactor/persistence.rb +107 -179
  60. data/lib/reactor/plans/common_attribute.rb +7 -7
  61. data/lib/reactor/plans/common_attribute_group.rb +6 -6
  62. data/lib/reactor/plans/common_channel.rb +6 -6
  63. data/lib/reactor/plans/common_group.rb +7 -14
  64. data/lib/reactor/plans/common_job.rb +6 -6
  65. data/lib/reactor/plans/common_obj_class.rb +11 -11
  66. data/lib/reactor/plans/create_attribute.rb +1 -3
  67. data/lib/reactor/plans/create_attribute_group.rb +1 -3
  68. data/lib/reactor/plans/create_channel.rb +2 -3
  69. data/lib/reactor/plans/create_group.rb +3 -10
  70. data/lib/reactor/plans/create_job.rb +3 -4
  71. data/lib/reactor/plans/create_obj.rb +12 -14
  72. data/lib/reactor/plans/create_obj_class.rb +1 -2
  73. data/lib/reactor/plans/delete_attribute.rb +1 -3
  74. data/lib/reactor/plans/delete_attribute_group.rb +2 -4
  75. data/lib/reactor/plans/delete_channel.rb +3 -6
  76. data/lib/reactor/plans/delete_group.rb +2 -9
  77. data/lib/reactor/plans/delete_job.rb +3 -5
  78. data/lib/reactor/plans/delete_obj.rb +3 -4
  79. data/lib/reactor/plans/delete_obj_class.rb +1 -2
  80. data/lib/reactor/plans/prepared.rb +3 -4
  81. data/lib/reactor/plans/rename_group.rb +4 -11
  82. data/lib/reactor/plans/rename_obj_class.rb +1 -2
  83. data/lib/reactor/plans/update_attribute.rb +1 -3
  84. data/lib/reactor/plans/update_attribute_group.rb +2 -4
  85. data/lib/reactor/plans/update_group.rb +2 -9
  86. data/lib/reactor/plans/update_job.rb +4 -8
  87. data/lib/reactor/plans/update_obj.rb +6 -7
  88. data/lib/reactor/plans/update_obj_class.rb +0 -2
  89. data/lib/reactor/rc_independent.rb +0 -1
  90. data/lib/reactor/session.rb +27 -31
  91. data/lib/reactor/session/observers.rb +3 -5
  92. data/lib/reactor/session/user.rb +6 -7
  93. data/lib/reactor/session_helper/auth_filter.rb +9 -0
  94. data/lib/reactor/session_helper/auth_helper.rb +24 -0
  95. data/lib/reactor/session_helper/rsession_helper.rb +16 -0
  96. data/lib/reactor/session_helper/session_state.rb +31 -0
  97. data/lib/reactor/streaming_upload.rb +0 -1
  98. data/lib/reactor/sudo.rb +2 -3
  99. data/lib/reactor/support/link_matcher.rb +8 -7
  100. data/lib/reactor/tools/migrator.rb +30 -35
  101. data/lib/reactor/tools/response_handler/xml_attribute.rb +27 -33
  102. data/lib/reactor/tools/smart_xml_logger.rb +20 -22
  103. data/lib/reactor/tools/sower.rb +22 -23
  104. data/lib/reactor/tools/uploader.rb +12 -17
  105. data/lib/reactor/tools/versioner.rb +29 -30
  106. data/lib/reactor/tools/where_query.rb +11 -14
  107. data/lib/reactor/tools/workflow_generator.rb +26 -28
  108. data/lib/reactor/tools/xml_attributes.rb +7 -14
  109. data/lib/reactor/tools/xpath_extractor.rb +2 -1
  110. data/lib/reactor/validations.rb +20 -16
  111. data/lib/reactor/version.rb +1 -2
  112. data/lib/reactor/workflow.rb +10 -33
  113. data/lib/reactor/workflow/comment.rb +28 -0
  114. data/lib/reactor/workflow/empty.rb +0 -1
  115. data/lib/reactor/workflow/standard.rb +4 -3
  116. data/lib/tasks/cm_migrate.rake +3 -3
  117. data/lib/tasks/cm_seeds.rake +9 -16
  118. metadata +72 -36
  119. data/app/models/rails_connector/abstract_model.rb +0 -7
  120. data/app/models/rails_connector/attribute.rb +0 -94
  121. data/app/models/rails_connector/blob_mapping.rb +0 -16
  122. data/app/models/rails_connector/channel.rb +0 -41
  123. data/app/models/rails_connector/content.rb +0 -12
  124. data/app/models/rails_connector/job.rb +0 -14
  125. data/app/models/rails_connector/obj_class.rb +0 -158
  126. data/app/models/rails_connector/obj_class_attr.rb +0 -5
  127. data/app/models/rails_connector/object_with_meta_data.rb +0 -18
  128. data/lib/rails_connector/meta/eager_loader.rb +0 -91
  129. data/lib/reactor/rails_connector_meta.rb +0 -149
  130. data/lib/reactor/session_helper.rb +0 -72
@@ -1,33 +1,40 @@
1
- # -*- encoding : utf-8 -*-
1
+ # return always utc-timestam in iso format 'YYYYMMDDhhmmss'
2
2
  module Reactor
3
3
  module Attributes
4
4
  class DateSerializer
5
- def initialize(attr, value)
6
- @attr, @value = attr, value
5
+ def initialize(key, value)
6
+ @attr = key
7
+ @value = value
7
8
  end
8
9
 
9
10
  def serialize
10
- @serialized ||= serialize_date
11
+ @serialized ||= serialize_date(@value)
11
12
  end
12
13
 
13
14
  private
14
- def serialize_date
15
- if @value.is_a?(Time)
16
- @value.dup.utc.to_iso
17
- elsif @value.is_a?(String)
18
- if iso_format?(@value)
19
- @value
20
- elsif !@value.empty?
21
- Time.zone.parse(@value).utc.to_iso
15
+
16
+ def serialize_date(value)
17
+ return nil if value.blank?
18
+
19
+ value = value.to_datetime if value.is_a?(Date)
20
+ if value.is_a?(Time) || value.is_a?(DateTime)
21
+ value.utc.to_s(:number)
22
+ elsif value.is_a?(String)
23
+ if iso_format?(value)
24
+ value
22
25
  else
23
- # empty string <=> clear date
24
- nil
26
+ parse_time(value)
25
27
  end
26
- else
27
- @value
28
28
  end
29
29
  end
30
30
 
31
+ def parse_time(value)
32
+ parsed_time = Time.zone.parse(value)
33
+ return nil unless parsed_time.present?
34
+
35
+ parsed_time.utc.to_s(:number)
36
+ end
37
+
31
38
  def iso_format?(val)
32
39
  val =~ /^[0-9]{14}$/
33
40
  end
@@ -1,11 +1,11 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/support/link_matcher'
1
+ require "reactor/support/link_matcher"
3
2
 
4
3
  module Reactor
5
4
  module Attributes
6
5
  class HTMLSerializer
7
6
  def initialize(attr, value)
8
- @attr, @value = attr, value.to_str
7
+ @attr = attr
8
+ @value = value.to_str
9
9
  end
10
10
 
11
11
  def serialize
@@ -13,13 +13,14 @@ module Reactor
13
13
  end
14
14
 
15
15
  private
16
+
16
17
  def serialize_html
17
18
  link_expressions = [/(href|src|usemap)\s*=\s*"([^"]*)"/, /(href|src|usemap)\s*=\s*'([^']*)'/]
18
19
  link_expressions.each do |expr|
19
20
  @value.gsub!(expr) do |string|
20
- link = Reactor::Support::LinkMatcher.new($2)
21
+ link = Reactor::Support::LinkMatcher.new(Regexp.last_match(2))
21
22
  if link.recognized?
22
- "#{$1}=\"#{link.rewrite_url}\""
23
+ "#{Regexp.last_match(1)}=\"#{link.rewrite_url}\""
23
24
  else
24
25
  string
25
26
  end
@@ -1,5 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/link/temporary_link'
1
+ require "reactor/link/temporary_link"
3
2
 
4
3
  module Reactor
5
4
  module Attributes
@@ -23,11 +22,13 @@ module Reactor
23
22
  # install #size_changed callback
24
23
  Array.instance_methods(false).each do |meth|
25
24
  old = instance_method(meth)
25
+ next unless meth.to_sym != :map
26
+
26
27
  define_method(meth) do |*args, &block|
27
28
  detect_modification do
28
29
  old.bind(self).call(*args, &block)
29
30
  end
30
- end if meth.to_sym != :map
31
+ end
31
32
  end
32
33
 
33
34
  def changed?
@@ -43,23 +44,24 @@ module Reactor
43
44
  end
44
45
 
45
46
  protected
47
+
46
48
  def link_ids
47
- self.map(&:id).compact
49
+ map(&:id).compact
48
50
  end
49
51
 
50
52
  def temporary_links_present?
51
- self.any? {|l| l.kind_of? Reactor::Link::TemporaryLink }
53
+ any? { |l| l.is_a? Reactor::Link::TemporaryLink }
52
54
  end
53
55
 
54
- def detect_modification(&block)
56
+ def detect_modification
55
57
  original_link_ids
56
58
  yield.tap do
57
- @changed = @changed || original_link_ids != link_ids
59
+ @changed ||= original_link_ids != link_ids
58
60
  end
59
61
  end
60
62
 
61
63
  def transform_into_link(link_data)
62
- if (link_data.respond_to?(:external?) && link_data.respond_to?(:internal?))
64
+ if link_data.respond_to?(:external?) && link_data.respond_to?(:internal?)
63
65
  link_data
64
66
  else
65
67
  Reactor::Link::TemporaryLink.new(link_data)
@@ -7,10 +7,11 @@ module Reactor
7
7
  end
8
8
 
9
9
  def call
10
- self.obj[self.attribute.to_sym] || RailsConnector::LinkList.new([])
10
+ obj[attribute.to_sym] || RailsConnector::LinkList.new([])
11
11
  end
12
12
 
13
13
  protected
14
+
14
15
  attr_accessor :obj, :attribute
15
16
  end
16
17
  end
@@ -7,12 +7,13 @@ module Reactor
7
7
  end
8
8
 
9
9
  def call
10
- (self.obj.attr_values[self.attribute.to_s] || []).map do |link_data|
10
+ (obj.attr_values[attribute.to_s] || []).map do |link_data|
11
11
  RailsConnector::Link.new(link_data)
12
12
  end
13
13
  end
14
14
 
15
15
  protected
16
+
16
17
  attr_accessor :obj, :attribute
17
18
  end
18
19
  end
@@ -1,13 +1,12 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'reactor/link/temporary_link'
3
- require 'infopark_fiona_connector'
4
- #require 'infopark_rails_connector'
1
+ require "reactor/link/temporary_link"
2
+ require "infopark_fiona_connector"
5
3
 
6
4
  module Reactor
7
5
  module Attributes
8
6
  class LinkListSerializer
9
7
  def initialize(attr, value)
10
- @attr, @value = attr, value
8
+ @attr = attr
9
+ @value = value
11
10
  end
12
11
 
13
12
  def serialize
@@ -20,10 +19,12 @@ module Reactor
20
19
  end
21
20
 
22
21
  private
22
+
23
23
  def enumerate(value)
24
24
  return [] if value.nil? || value.blank?
25
- return [value] unless value.kind_of?(Array)
26
- return value
25
+ return [value] unless value.is_a?(Array)
26
+
27
+ value
27
28
  end
28
29
  end
29
30
  end
@@ -0,0 +1,164 @@
1
+ require "reactor/attributes/date_serializer"
2
+ require "reactor/attributes/html_serializer"
3
+ require "reactor/attributes/link_list_serializer"
4
+
5
+ require "reactor/attributes/link_list_extender"
6
+
7
+ require "singleton"
8
+
9
+ module Reactor
10
+ class AttributeHandlers
11
+ include Singleton
12
+
13
+ def initialize
14
+ # t1 = Time.now
15
+ generate_attribute_handlers
16
+ # Rails.logger.debug "Reactor::AttributeHandlers: generate_attribute_handlers took #{Time.now - t1}"
17
+ end
18
+
19
+ # Use this method to install attributes into class
20
+ def self.install_attributes(klass)
21
+ Reactor::AttributeHandlers.instance.install(klass, obj_class(klass))
22
+ end
23
+
24
+ # Use this method if attributes changed and you wish to reinstall them
25
+ def self.reinstall_attributes(klass, obj_class)
26
+ Reactor::AttributeHandlers.instance.tap do |handler|
27
+ handler.regenerate_attribute_handler(obj_class)
28
+ handler.install(klass, obj_class)
29
+ end
30
+ end
31
+
32
+ def self.obj_class(klass)
33
+ klass.name.split("::").last
34
+ end
35
+
36
+ def install(klass, obj_class)
37
+ klass.send(:include, handler_module(obj_class)) if obj_class_known?(obj_class)
38
+ end
39
+
40
+ def regenerate_attribute_handler(obj_class_name)
41
+ generate_attribute_handler(RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class_name))
42
+ end
43
+
44
+ protected
45
+
46
+ def handler_module(obj_class)
47
+ Reactor::AttributeHandlers.const_get("Handler__" + obj_class.to_s)
48
+ end
49
+
50
+ def obj_class_known?(obj_class)
51
+ Reactor::AttributeHandlers.const_defined?("Handler__" + obj_class.to_s)
52
+ end
53
+
54
+ def generate_attribute_handlers
55
+ RailsConnector::Meta::EagerLoader.instance.obj_classes.each do |_, obj_class|
56
+ # Rails.logger.debug "Reactor::AttributeHandlers: preparing obj class #{obj_class.name}"
57
+ generate_attribute_handler(obj_class) if /^[A-Z]/.match?(obj_class.try(:name))
58
+ end
59
+ end
60
+
61
+ def generate_attribute_handler(obj_class)
62
+ # Rails.logger.debug "Reactor::AttributeHandlers: generating handler for #{obj_class.name}"
63
+ attribute_methods = []
64
+ writers = []
65
+
66
+ obj_class.custom_attributes.each do |attribute, attribute_data|
67
+ writers << attribute.to_sym
68
+ writers << attribute.to_s.underscore.to_sym
69
+
70
+ # Custom attribute readers: prevent unwanted nils
71
+ case attribute_data.attribute_type.to_sym
72
+ when :html
73
+ attribute_methods << <<-EOC
74
+ def #{attribute}
75
+ self[:#{attribute}] || ''.html_safe
76
+ end
77
+ EOC
78
+ when :date, :enum
79
+ attribute_methods << <<-EOC
80
+ def #{attribute}
81
+ self[:#{attribute}]
82
+ end
83
+ EOC
84
+ when :linklist
85
+ attribute_methods << <<-EOC
86
+ def #{attribute}
87
+ self[:#{attribute}] || RailsConnector::LinkList.new([])
88
+ end
89
+ EOC
90
+ when :multienum
91
+ attribute_methods << <<-EOC
92
+ def #{attribute}
93
+ self[:#{attribute}] || []
94
+ end
95
+ EOC
96
+ else
97
+ attribute_methods << <<-EOC
98
+ def #{attribute}
99
+ self[:#{attribute}] || ''
100
+ end
101
+ EOC
102
+ end
103
+
104
+ # active model dirty tracking
105
+ attribute_methods << <<-EOC
106
+ def #{attribute}_changed?(**options)
107
+ attribute_changed?(:#{attribute}, options)
108
+ end
109
+ EOC
110
+ end
111
+
112
+ [:contentType].each do |attribute|
113
+ writers << attribute.to_sym
114
+ writers << attribute.to_s.underscore.to_sym
115
+ end
116
+
117
+ Reactor::Cm::Obj::OBJ_ATTRS.each do |attribute|
118
+ writers << attribute.to_sym
119
+ writers << attribute.to_s.underscore.to_sym
120
+ end
121
+
122
+ writers.uniq!
123
+
124
+ writers.each do |attribute|
125
+ attribute_methods << <<-EOC
126
+ def #{attribute}=(value)
127
+ set(:#{attribute},value)
128
+ end
129
+ EOC
130
+ end
131
+
132
+ # if a handler for this obj class has been defined previously, purge its methods
133
+ if Reactor::AttributeHandlers.const_defined?("Handler__#{obj_class.name}")
134
+ mod = Reactor::AttributeHandlers.const_get("Handler__#{obj_class.name}")
135
+ mod.instance_methods.each do |method|
136
+ mod.send(:remove_method, method)
137
+ end
138
+ end
139
+
140
+ Reactor.class_eval <<-EOC
141
+ class AttributeHandlers
142
+ module Handler__#{obj_class.name}
143
+ def self.included(base)
144
+ # store allowed attributes
145
+ allowed_attrs = %w|#{writers * " "}|.map(&:to_sym)
146
+ base.send(:instance_variable_set, '@_o_allowed_attrs', allowed_attrs)
147
+ end
148
+
149
+ # attribute readers and writers
150
+ #{attribute_methods.join("\n")}
151
+
152
+ # parent-setting handling
153
+ def parent=(parent_something)
154
+ set_parent(parent_something)
155
+ end
156
+ end
157
+ end
158
+ EOC
159
+
160
+ handler_module(obj_class.name)
161
+ # "Reactor::AttributeHandlers::Handler__#{obj_class.name}"
162
+ end
163
+ end
164
+ end
@@ -1,32 +1,29 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Reactor
4
2
  module Cache
5
3
  class Permission
6
4
  BACKING_CACHE_EXPIRATION = 5
7
5
 
8
6
  def self.instance
9
- self.new
7
+ new
10
8
  end
11
9
 
12
10
  def initialize
13
11
  @@backing_storage ||= ActiveSupport::Cache::MemoryStore.new({ size: 1.megabyte })
14
12
  end
15
13
 
16
- def lookup(user, key, &block)
17
- cache_entry = @@backing_storage.fetch(user.to_s, :expires_in => BACKING_CACHE_EXPIRATION.minutes) do
18
- {key => block.call}
14
+ def lookup(user, key)
15
+ cache_entry = @@backing_storage.fetch(user.to_s, expires_in: BACKING_CACHE_EXPIRATION.minutes) do
16
+ { key => yield }
19
17
  end
20
18
  if cache_entry.key?(key)
21
19
  cache_entry[key]
22
20
  else
23
- result = block.call
24
- @@backing_storage.write(user.to_s, cache_entry.merge({key => result}), :expires_in => BACKING_CACHE_EXPIRATION.minutes)
21
+ result = yield
22
+ @@backing_storage.write(user.to_s, cache_entry.merge({ key => result }), expires_in: BACKING_CACHE_EXPIRATION.minutes)
25
23
  result
26
24
  end
27
25
  end
28
26
 
29
-
30
27
  def invalidate(user)
31
28
  @@backing_storage.delete(user.to_s)
32
29
  end
@@ -1,12 +1,10 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
1
  module Reactor
4
2
  module Cache
5
3
  class User
6
4
  BACKING_CACHE_EXPIRATION = 5
7
5
 
8
6
  def self.instance
9
- self.new
7
+ new
10
8
  end
11
9
 
12
10
  def initialize
@@ -18,19 +16,18 @@ module Reactor
18
16
  # Rails.logger.debug "User:Cache hit: #{hit?(user_name.to_s)} [#{@cache[user_name.to_s].inspect}]"
19
17
 
20
18
  key = user_name.to_s
21
- @@backing_storage.fetch(key, :expires_in => BACKING_CACHE_EXPIRATION.minutes) do
19
+ @@backing_storage.fetch(key, expires_in: BACKING_CACHE_EXPIRATION.minutes) do
22
20
  Reactor::Session::User.new(key)
23
21
  end
24
22
  end
25
23
 
26
24
  def set(user_name, user)
27
- @@backing_storage.write(user_name.to_s, user, :expires_in => BACKING_CACHE_EXPIRATION.minutes)
25
+ @@backing_storage.write(user_name.to_s, user, expires_in: BACKING_CACHE_EXPIRATION.minutes)
28
26
  end
29
27
 
30
28
  def invalidate(user_name)
31
29
  @@backing_storage.delete(user_name.to_s)
32
30
  end
33
-
34
31
  end
35
32
  end
36
33
  end
@@ -1,30 +1,29 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Reactor
3
2
  module Cm
4
3
  class Attribute
5
4
  def self.exists?(name)
6
5
  begin
7
- return Attribute.new.send(:get,name).ok?
8
- rescue
9
- return false
6
+ Attribute.new.send(:get, name).ok?
7
+ rescue StandardError
8
+ false
10
9
  end
11
10
  end
12
11
 
13
12
  def self.instance(name)
14
13
  attr = Attribute.new
15
- attr.instance_variable_set('@name', name)
14
+ attr.instance_variable_set("@name", name)
16
15
  attr
17
16
  end
18
17
 
19
18
  def self.get(name)
20
19
  attr = Attribute.new
21
- attr.send(:get,name)
20
+ attr.send(:get, name)
22
21
  attr
23
22
  end
24
23
 
25
24
  def self.create(name, type)
26
25
  attr = Attribute.new
27
- attr.send(:create,name,type)
26
+ attr.send(:create, name, type)
28
27
  attr
29
28
  end
30
29
 
@@ -34,27 +33,28 @@ module Reactor
34
33
 
35
34
  def save!
36
35
  request = XmlRequest.prepare do |xml|
37
- xml.where_key_tag!(base_name, 'name', @name)
36
+ xml.where_key_tag!(base_name, "name", @name)
38
37
  xml.set_tag!(base_name) do
39
38
  @params.each do |key, value|
40
39
  xml.value_tag!(key.to_s, value)
41
40
  end
42
41
  end
43
42
  end
44
- response = request.execute!
43
+ request.execute!
45
44
  end
46
45
 
47
46
  def delete!
48
47
  request = XmlRequest.prepare do |xml|
49
- xml.where_key_tag!(base_name, 'name', @name)
48
+ xml.where_key_tag!(base_name, "name", @name)
50
49
  xml.tag!("#{base_name}-delete")
51
50
  end
52
- response = request.execute!
51
+ request.execute!
53
52
  end
54
53
 
55
54
  protected
55
+
56
56
  def base_name
57
- 'attribute'
57
+ "attribute"
58
58
  end
59
59
 
60
60
  def initialize
@@ -63,8 +63,8 @@ module Reactor
63
63
 
64
64
  def get(name)
65
65
  request = XmlRequest.prepare do |xml|
66
- xml.where_key_tag!(base_name, 'name', name)
67
- xml.get_key_tag!(base_name, 'name')
66
+ xml.where_key_tag!(base_name, "name", name)
67
+ xml.get_key_tag!(base_name, "name")
68
68
  end
69
69
  response = request.execute!
70
70
  @name = name
@@ -74,10 +74,10 @@ module Reactor
74
74
  def create(name, type)
75
75
  request = XmlRequest.prepare do |xml|
76
76
  xml.create_tag!(base_name) do
77
- xml.tag!('name') do
77
+ xml.tag!("name") do
78
78
  xml.text!(name)
79
79
  end
80
- xml.tag!('type') do
80
+ xml.tag!("type") do
81
81
  xml.text!(type)
82
82
  end
83
83
  end