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.
- checksums.yaml +4 -4
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +363 -0
- data/Rakefile +10 -13
- data/app/models/rails_connector/abstract_obj.rb +2 -1
- data/config/routes.rb +0 -1
- data/infopark_reactor.gemspec +16 -15
- data/lib/generators/cm/migration/migration_generator.rb +4 -8
- data/lib/infopark_reactor.rb +43 -69
- data/lib/reactor/already_released.rb +1 -2
- data/lib/reactor/attributes.rb +92 -268
- data/lib/reactor/attributes/date_serializer.rb +23 -16
- data/lib/reactor/attributes/html_serializer.rb +6 -5
- data/lib/reactor/attributes/link_list_extender.rb +10 -8
- data/lib/reactor/attributes/link_list_from_accessor.rb +2 -1
- data/lib/reactor/attributes/link_list_from_attr_values.rb +2 -1
- data/lib/reactor/attributes/link_list_serializer.rb +8 -7
- data/lib/reactor/attributes_handlers.rb +164 -0
- data/lib/reactor/cache/permission.rb +6 -9
- data/lib/reactor/cache/user.rb +3 -6
- data/lib/reactor/cm/attribute.rb +16 -16
- data/lib/reactor/cm/attribute_group.rb +18 -21
- data/lib/reactor/cm/blob_too_small_error.rb +2 -2
- data/lib/reactor/cm/bridge.rb +6 -9
- data/lib/reactor/cm/channel.rb +3 -4
- data/lib/reactor/cm/editorial_group.rb +2 -9
- data/lib/reactor/cm/group.rb +30 -43
- data/lib/reactor/cm/job.rb +23 -25
- data/lib/reactor/cm/language.rb +21 -22
- data/lib/reactor/cm/link.rb +38 -40
- data/lib/reactor/cm/live_group.rb +2 -9
- data/lib/reactor/cm/log_entry.rb +22 -21
- data/lib/reactor/cm/missing_credentials.rb +3 -2
- data/lib/reactor/cm/multi_xml_request.rb +22 -25
- data/lib/reactor/cm/obj.rb +159 -154
- data/lib/reactor/cm/obj_class.rb +52 -51
- data/lib/reactor/cm/object_base.rb +26 -21
- data/lib/reactor/cm/permissions.rb +7 -7
- data/lib/reactor/cm/user.rb +43 -51
- data/lib/reactor/cm/workflow.rb +11 -12
- data/lib/reactor/cm/xml_attribute.rb +10 -19
- data/lib/reactor/cm/xml_markup.rb +7 -10
- data/lib/reactor/cm/xml_multi_request_error.rb +1 -3
- data/lib/reactor/cm/xml_request.rb +21 -29
- data/lib/reactor/cm/xml_request_error.rb +1 -3
- data/lib/reactor/cm/xml_response.rb +8 -16
- data/lib/reactor/cm/xml_single_request_error.rb +3 -5
- data/lib/reactor/configuration.rb +1 -3
- data/lib/reactor/engine.rb +5 -10
- data/lib/reactor/legacy.rb +6 -7
- data/lib/reactor/link/external.rb +8 -5
- data/lib/reactor/link/internal.rb +8 -5
- data/lib/reactor/link/temporary_link.rb +16 -17
- data/lib/reactor/main.rb +11 -15
- data/lib/reactor/migration.rb +52 -53
- data/lib/reactor/no_working_version.rb +1 -2
- data/lib/reactor/not_permitted.rb +1 -2
- data/lib/reactor/permission.rb +36 -38
- data/lib/reactor/persistence.rb +107 -179
- data/lib/reactor/plans/common_attribute.rb +7 -7
- data/lib/reactor/plans/common_attribute_group.rb +6 -6
- data/lib/reactor/plans/common_channel.rb +6 -6
- data/lib/reactor/plans/common_group.rb +7 -14
- data/lib/reactor/plans/common_job.rb +6 -6
- data/lib/reactor/plans/common_obj_class.rb +11 -11
- data/lib/reactor/plans/create_attribute.rb +1 -3
- data/lib/reactor/plans/create_attribute_group.rb +1 -3
- data/lib/reactor/plans/create_channel.rb +2 -3
- data/lib/reactor/plans/create_group.rb +3 -10
- data/lib/reactor/plans/create_job.rb +3 -4
- data/lib/reactor/plans/create_obj.rb +12 -14
- data/lib/reactor/plans/create_obj_class.rb +1 -2
- data/lib/reactor/plans/delete_attribute.rb +1 -3
- data/lib/reactor/plans/delete_attribute_group.rb +2 -4
- data/lib/reactor/plans/delete_channel.rb +3 -6
- data/lib/reactor/plans/delete_group.rb +2 -9
- data/lib/reactor/plans/delete_job.rb +3 -5
- data/lib/reactor/plans/delete_obj.rb +3 -4
- data/lib/reactor/plans/delete_obj_class.rb +1 -2
- data/lib/reactor/plans/prepared.rb +3 -4
- data/lib/reactor/plans/rename_group.rb +4 -11
- data/lib/reactor/plans/rename_obj_class.rb +1 -2
- data/lib/reactor/plans/update_attribute.rb +1 -3
- data/lib/reactor/plans/update_attribute_group.rb +2 -4
- data/lib/reactor/plans/update_group.rb +2 -9
- data/lib/reactor/plans/update_job.rb +4 -8
- data/lib/reactor/plans/update_obj.rb +6 -7
- data/lib/reactor/plans/update_obj_class.rb +0 -2
- data/lib/reactor/rc_independent.rb +0 -1
- data/lib/reactor/session.rb +27 -31
- data/lib/reactor/session/observers.rb +3 -5
- data/lib/reactor/session/user.rb +6 -7
- data/lib/reactor/session_helper/auth_filter.rb +9 -0
- data/lib/reactor/session_helper/auth_helper.rb +24 -0
- data/lib/reactor/session_helper/rsession_helper.rb +16 -0
- data/lib/reactor/session_helper/session_state.rb +31 -0
- data/lib/reactor/streaming_upload.rb +0 -1
- data/lib/reactor/sudo.rb +2 -3
- data/lib/reactor/support/link_matcher.rb +8 -7
- data/lib/reactor/tools/migrator.rb +30 -35
- data/lib/reactor/tools/response_handler/xml_attribute.rb +27 -33
- data/lib/reactor/tools/smart_xml_logger.rb +20 -22
- data/lib/reactor/tools/sower.rb +22 -23
- data/lib/reactor/tools/uploader.rb +12 -17
- data/lib/reactor/tools/versioner.rb +29 -30
- data/lib/reactor/tools/where_query.rb +11 -14
- data/lib/reactor/tools/workflow_generator.rb +26 -28
- data/lib/reactor/tools/xml_attributes.rb +7 -14
- data/lib/reactor/tools/xpath_extractor.rb +2 -1
- data/lib/reactor/validations.rb +20 -16
- data/lib/reactor/version.rb +1 -2
- data/lib/reactor/workflow.rb +10 -33
- data/lib/reactor/workflow/comment.rb +28 -0
- data/lib/reactor/workflow/empty.rb +0 -1
- data/lib/reactor/workflow/standard.rb +4 -3
- data/lib/tasks/cm_migrate.rake +3 -3
- data/lib/tasks/cm_seeds.rake +9 -16
- metadata +72 -36
- data/app/models/rails_connector/abstract_model.rb +0 -7
- data/app/models/rails_connector/attribute.rb +0 -94
- data/app/models/rails_connector/blob_mapping.rb +0 -16
- data/app/models/rails_connector/channel.rb +0 -41
- data/app/models/rails_connector/content.rb +0 -12
- data/app/models/rails_connector/job.rb +0 -14
- data/app/models/rails_connector/obj_class.rb +0 -158
- data/app/models/rails_connector/obj_class_attr.rb +0 -5
- data/app/models/rails_connector/object_with_meta_data.rb +0 -18
- data/lib/rails_connector/meta/eager_loader.rb +0 -91
- data/lib/reactor/rails_connector_meta.rb +0 -149
- data/lib/reactor/session_helper.rb +0 -72
data/lib/reactor/cm/workflow.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
|
-
|
2
|
-
require 'reactor/cm/object_base'
|
1
|
+
require "reactor/cm/object_base"
|
3
2
|
|
4
3
|
module Reactor
|
5
4
|
module Cm
|
6
5
|
class Workflow < ObjectBase
|
7
6
|
# Attribute definitions
|
8
|
-
attribute :name, :
|
7
|
+
attribute :name, except: [:set]
|
9
8
|
attribute :title
|
10
|
-
attribute :is_enabled, :
|
11
|
-
attribute :edit_groups, :
|
12
|
-
attribute :mutiple_signatures, :
|
9
|
+
attribute :is_enabled, name: :isEnabled
|
10
|
+
attribute :edit_groups, name: :editGroups, type: :list
|
11
|
+
attribute :mutiple_signatures, name: :allowsMultipleSignatures
|
13
12
|
# This attribute should be used as follows:
|
14
13
|
# workflow.signatures = [{:attribute => 'mySigAttr', :group => 'myGroup'},{:attribute => 'mySigAttr', :group => 'myOtherGroup'}]
|
15
|
-
attribute :signatures, :
|
14
|
+
attribute :signatures, name: :signatureDefs, type: :signaturelist
|
16
15
|
|
17
16
|
primary_key :name
|
18
17
|
|
19
18
|
# Creates a workflow with given name. A list of edit groups
|
20
19
|
# may also be specified - otherwise it defaults to empty list
|
21
20
|
def self.create(name, edit_groups = [])
|
22
|
-
super(name, {:
|
21
|
+
super(name, { name: name, editGroups: edit_groups })
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.serialize_attribute_to_xml(xml, xml_attribute, value)
|
26
25
|
if xml_attribute.name.to_sym == :signatureDefs
|
27
|
-
xml.tag!(
|
26
|
+
xml.tag!("signatureDefs") do
|
28
27
|
(value || []).each do |hash|
|
29
|
-
xml.tag!(
|
30
|
-
xml.tag!(
|
31
|
-
xml.tag!(
|
28
|
+
xml.tag!("listitem") do
|
29
|
+
xml.tag!("listitem", hash[:attribute])
|
30
|
+
xml.tag!("listitem", hash[:group])
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -1,36 +1,27 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
|
-
|
4
2
|
module Cm
|
5
|
-
|
6
3
|
class XmlAttribute
|
4
|
+
AVAILABLE_SCOPES = %i(get set create).freeze
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor :name
|
11
|
-
attr_accessor :type
|
12
|
-
attr_accessor :scopes
|
6
|
+
attr_accessor :name, :type, :scopes
|
13
7
|
|
14
8
|
def initialize(name, type, options)
|
15
9
|
@name = name
|
16
10
|
@type = type.presence || :string
|
17
11
|
|
18
12
|
@scopes =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
if options[:except].present?
|
14
|
+
AVAILABLE_SCOPES - options[:except]
|
15
|
+
elsif options[:only].present?
|
16
|
+
options[:only]
|
17
|
+
else
|
18
|
+
AVAILABLE_SCOPES
|
19
|
+
end
|
26
20
|
end
|
27
21
|
|
28
22
|
def scope?(name)
|
29
|
-
|
23
|
+
scopes.include?(name)
|
30
24
|
end
|
31
|
-
|
32
25
|
end
|
33
|
-
|
34
26
|
end
|
35
|
-
|
36
27
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'builder'
|
1
|
+
require "builder"
|
3
2
|
|
4
3
|
module Reactor
|
5
4
|
module Cm
|
6
5
|
class XmlMarkup < Builder::XmlMarkup
|
7
|
-
|
8
6
|
def where_key_tag!(base_name, key, value)
|
9
7
|
where_tag!(base_name) do |xml|
|
10
8
|
xml.tag!(key.to_s) do
|
@@ -31,10 +29,10 @@ module Reactor
|
|
31
29
|
|
32
30
|
def get_key_tag!(base_name, key)
|
33
31
|
get_tag!(base_name) do |xml|
|
34
|
-
if key.
|
35
|
-
key.each {|k| xml.tag!(k.to_s) }
|
32
|
+
if key.is_a?(::Array)
|
33
|
+
key.each { |k| xml.tag!(k.to_s) }
|
36
34
|
else
|
37
|
-
xml.tag!(key.to_s)
|
35
|
+
xml.tag!(key.to_s); end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
@@ -57,8 +55,8 @@ module Reactor
|
|
57
55
|
end
|
58
56
|
|
59
57
|
def value_tag!(key, value, options = {})
|
60
|
-
if value.
|
61
|
-
elsif value.
|
58
|
+
if value.is_a? ::Array then array_value_tag!(key, value, options)
|
59
|
+
elsif value.is_a? ::Hash then hash_value_tag!(key, value)
|
62
60
|
else tag!(key.to_s) { text!(value.to_s) }
|
63
61
|
end
|
64
62
|
end
|
@@ -66,7 +64,7 @@ module Reactor
|
|
66
64
|
def array_value_tag!(name, values, options = {})
|
67
65
|
tag!(name.to_s, options) do
|
68
66
|
values.each do |value|
|
69
|
-
tag!(
|
67
|
+
tag!("listitem") do
|
70
68
|
text!(value.to_s)
|
71
69
|
end
|
72
70
|
end
|
@@ -80,7 +78,6 @@ module Reactor
|
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
83
|
-
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
@@ -1,21 +1,14 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'reactor/tools/smart_xml_logger'
|
1
|
+
require "net/http"
|
2
|
+
require "reactor/cm/xml_response"
|
3
|
+
require "reactor/cm/xml_single_request_error"
|
4
|
+
require "reactor/cm/xml_markup"
|
5
|
+
require "reactor/tools/smart_xml_logger"
|
7
6
|
|
8
7
|
module Reactor
|
9
8
|
module Cm
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
LOGGER = SmartXmlLogger.new(Kernel, :puts)
|
14
|
-
else
|
15
|
-
LOGGER = SmartXmlLogger.new(nil) # turn off logging
|
16
|
-
end
|
17
|
-
LOGGER.configure(:request, :xpath => 'cm-payload/cm-request/*', :start_indent => 2)
|
18
|
-
LOGGER.configure(:response, :xpath => 'cm-payload/cm-response/*', :start_indent => 2)
|
9
|
+
LOGGER = SmartXmlLogger.new(nil) # turn off logging
|
10
|
+
LOGGER.configure(:request, xpath: "cm-payload/cm-request/*", start_indent: 2)
|
11
|
+
LOGGER.configure(:response, xpath: "cm-payload/cm-response/*", start_indent: 2)
|
19
12
|
|
20
13
|
class XmlRequest
|
21
14
|
cattr_accessor :timeout
|
@@ -26,18 +19,17 @@ module Reactor
|
|
26
19
|
end
|
27
20
|
|
28
21
|
def self.prepare
|
29
|
-
access = Configuration
|
22
|
+
access = Configuration.xml_access
|
30
23
|
sanity_check(access)
|
31
24
|
xml = XmlMarkup.new
|
32
|
-
ret = nil
|
33
25
|
xml.instruct!
|
34
|
-
ret = xml.tag!(
|
35
|
-
xml.tag!(
|
36
|
-
xml.tag!(
|
37
|
-
xml.tag!(
|
26
|
+
ret = xml.tag!("cm-payload", "payload-id" => "abcabc", "timestamp" => Time.now.getutc.strftime("%Y%m%d%H%M%S"), "version" => "6.7.3") do
|
27
|
+
xml.tag!("cm-header") do
|
28
|
+
xml.tag!("cm-sender", "sender-id" => access[:id], "name" => "ruby-simple-client")
|
29
|
+
xml.tag!("cm-authentication", "login" => access[:username], "token" => token(access[:username], access[:secret]))
|
38
30
|
end
|
39
|
-
id =
|
40
|
-
xml.tag!(
|
31
|
+
id = generate_id
|
32
|
+
xml.tag!("cm-request", "request-id" => id) do |xml2|
|
41
33
|
yield xml2 if block_given?
|
42
34
|
end
|
43
35
|
end
|
@@ -45,21 +37,22 @@ module Reactor
|
|
45
37
|
end
|
46
38
|
|
47
39
|
def execute!
|
48
|
-
access = Configuration
|
40
|
+
access = Configuration.xml_access
|
49
41
|
payload = @xml
|
50
42
|
|
51
43
|
res = Net::HTTP.new(access[:host], access[:port]).start do |http|
|
52
44
|
http.read_timeout = self.class.timeout
|
53
|
-
req = Net::HTTP::Post.new(
|
54
|
-
Reactor::Cm::LOGGER.log(
|
45
|
+
req = Net::HTTP::Post.new("/xml")
|
46
|
+
Reactor::Cm::LOGGER.log("REQUEST:")
|
55
47
|
Reactor::Cm::LOGGER.log_xml(:request, payload)
|
56
48
|
req.body = payload
|
57
49
|
http.request(req)
|
58
50
|
end
|
59
|
-
Reactor::Cm::LOGGER.log(
|
51
|
+
Reactor::Cm::LOGGER.log("RESPONSE:")
|
60
52
|
Reactor::Cm::LOGGER.log_xml(:response, res.body)
|
61
53
|
response = XmlResponse.new(res.body)
|
62
54
|
raise XmlSingleRequestError, response unless response.ok?
|
55
|
+
|
63
56
|
response
|
64
57
|
end
|
65
58
|
|
@@ -67,7 +60,7 @@ module Reactor
|
|
67
60
|
protected
|
68
61
|
|
69
62
|
def generate_id
|
70
|
-
rand(
|
63
|
+
rand(10_000)
|
71
64
|
end
|
72
65
|
|
73
66
|
def sanity_check(access)
|
@@ -80,7 +73,6 @@ module Reactor
|
|
80
73
|
def initialize(xml)
|
81
74
|
@xml = xml
|
82
75
|
end
|
83
|
-
|
84
76
|
end
|
85
77
|
end
|
86
78
|
end
|
@@ -1,16 +1,11 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'rexml/document'
|
1
|
+
require "reactor/tools/response_handler/xml_attribute"
|
2
|
+
require "reactor/tools/xpath_extractor"
|
3
|
+
require "rexml/document"
|
5
4
|
|
6
5
|
module Reactor
|
7
|
-
|
8
6
|
module Cm
|
9
|
-
|
10
7
|
class XmlResponse
|
11
|
-
|
12
|
-
attr_reader :xml
|
13
|
-
attr_reader :xml_str
|
8
|
+
attr_reader :xml, :xml_str
|
14
9
|
|
15
10
|
def initialize(xml)
|
16
11
|
@xml_str = xml
|
@@ -24,19 +19,16 @@ module Reactor
|
|
24
19
|
end
|
25
20
|
|
26
21
|
def ok?
|
27
|
-
xp = xpath(
|
22
|
+
xp = xpath("//cm-code")
|
28
23
|
|
29
24
|
if xp.is_a?(Array)
|
30
|
-
codes = xp.map { |result| result.attribute(
|
25
|
+
codes = xp.map { |result| result.attribute("numeric").value }.uniq
|
31
26
|
|
32
|
-
return codes.size == 1 && codes.first ==
|
27
|
+
return codes.size == 1 && codes.first == "200"
|
33
28
|
end
|
34
29
|
|
35
|
-
xp.attribute(
|
30
|
+
xp.attribute("numeric").value == "200"
|
36
31
|
end
|
37
|
-
|
38
32
|
end
|
39
|
-
|
40
33
|
end
|
41
|
-
|
42
34
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'reactor/cm/xml_request_error'
|
1
|
+
require "reactor/cm/xml_request_error"
|
3
2
|
|
4
3
|
module Reactor
|
5
4
|
module Cm
|
@@ -10,12 +9,11 @@ module Reactor
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def phrase
|
13
|
-
result = @response.xpath(
|
14
|
-
result = [result] unless result.
|
12
|
+
result = @response.xpath("//phrase/text()")
|
13
|
+
result = [result] unless result.is_a?(Array)
|
15
14
|
|
16
15
|
result.map(&:to_s).join("\n")
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/lib/reactor/engine.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'reactor/session_helper'
|
2
|
-
|
3
|
-
# -*- encoding : utf-8 -*-
|
4
1
|
module Reactor
|
5
|
-
|
6
2
|
class Engine < Rails::Engine
|
7
3
|
rake_tasks do
|
8
4
|
load "tasks/cm_migrate.rake"
|
@@ -10,18 +6,17 @@ module Reactor
|
|
10
6
|
end
|
11
7
|
|
12
8
|
initializer "reactor.upgrade" do
|
13
|
-
if Gem::Specification.find_all_by_name(
|
9
|
+
if Gem::Specification.find_all_by_name("infopark_reactor_migrations").any? || Gem::Specification.find_all_by_name("infopark_rails_connector_meta").any?
|
14
10
|
raise "Please remove 'infopark_reactor_migrations' and 'infopark_rails_connector_meta' from your Gemfile. They are deprecated and no longer needed."
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
18
|
-
initializer "reactor.rsession" do |
|
19
|
-
ActionController::Base.
|
14
|
+
initializer "reactor.rsession" do |_app|
|
15
|
+
ActionController::Base.include Reactor::SessionHelper::RsessionHelper
|
20
16
|
ActionController::Base.__send__(:helper_method, :rsession)
|
21
17
|
|
22
|
-
ActionController::Base.
|
18
|
+
ActionController::Base.include Reactor::SessionHelper::AuthHelper
|
19
|
+
ActionController::Base.include Reactor::SessionHelper::AuthFilter
|
23
20
|
end
|
24
|
-
|
25
21
|
end
|
26
|
-
|
27
22
|
end
|
data/lib/reactor/legacy.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
# This is a collection of legacy method,s that have not found any better place to live.
|
4
3
|
module Legacy
|
@@ -11,14 +10,14 @@ module Reactor
|
|
11
10
|
# @option options :no_children if true prevents deletion unless there are no children
|
12
11
|
# @option options :img_children_only if true prevents deletion unless there are exclusively img children
|
13
12
|
# @option options [Array] :children if true prevents deletion if there are other children besides the specified ones (array of names)
|
14
|
-
def delete_children!(options={})
|
13
|
+
def delete_children!(options = {})
|
15
14
|
# TODO: provide better discrimination mechanisms (blocks?)
|
16
15
|
f_nochild = options.delete(:no_children)
|
17
16
|
f_imgchild = options.delete(:img_children_only)
|
18
17
|
f_children = options.delete(:children)
|
19
18
|
|
20
|
-
mychildren
|
21
|
-
|
19
|
+
mychildren = children
|
20
|
+
other_children = mychildren.reject { |obj| obj.obj_class == "Image" }
|
22
21
|
|
23
22
|
# are there any links pointing to this container
|
24
23
|
return false if has_super_links?
|
@@ -27,16 +26,16 @@ module Reactor
|
|
27
26
|
# is the flag set and are there any children besides images
|
28
27
|
return false if f_imgchild && !other_children.empty?
|
29
28
|
# is the flag set and are there any children besides the specified ones
|
30
|
-
return false if f_children && !(
|
29
|
+
return false if f_children && !(mychildren.map(&:name) - f_children).empty?
|
31
30
|
|
32
31
|
# check children for any links pointing to them
|
33
32
|
return false if mychildren.detect(&:has_super_links?)
|
34
33
|
# check if there are any grandchildren
|
35
|
-
return false if mychildren.detect {|child| !child.children.empty?}
|
34
|
+
return false if mychildren.detect { |child| !child.children.empty? }
|
36
35
|
|
37
36
|
# delete children
|
38
37
|
mychildren.each(&:destroy)
|
39
|
-
|
38
|
+
true
|
40
39
|
end
|
41
40
|
end
|
42
41
|
module ClassMethods
|
@@ -1,15 +1,18 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module Reactor
|
3
2
|
module Link
|
4
3
|
class External
|
5
4
|
attr_accessor :url
|
6
5
|
|
7
|
-
def external?
|
8
|
-
|
6
|
+
def external?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def internal?
|
11
|
+
false
|
12
|
+
end
|
9
13
|
|
10
|
-
def initialize(
|
14
|
+
def initialize(_url)
|
11
15
|
raise TypeError, "#{self.class.name} is deprecated!"
|
12
|
-
self.url = url
|
13
16
|
end
|
14
17
|
|
15
18
|
def id
|