focus-utils 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ares/add_relative_prefix.rb +60 -0
- data/lib/focus-utils.rb +2 -0
- metadata +2 -1
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ActiveResource
|
4
|
+
module Extend
|
5
|
+
module AddRelativePrefix
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class << self
|
10
|
+
alias_method_chain :element_path, :relative_prefix
|
11
|
+
alias_method_chain :new_element_path, :relative_prefix
|
12
|
+
alias_method_chain :collection_path, :relative_prefix
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def relative_prefix
|
18
|
+
# Not using superclass_delegating_reader. See +site+ for explanation
|
19
|
+
if defined?(@relative_prefix)
|
20
|
+
@relative_prefix
|
21
|
+
elsif superclass != Object && superclass.relative_prefix
|
22
|
+
superclass.relative_prefix.dup.freeze
|
23
|
+
else
|
24
|
+
""
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def relative_prefix=(relative_prefix)
|
29
|
+
@relative_prefix = relative_prefix
|
30
|
+
end
|
31
|
+
|
32
|
+
def custom_method_collection_url(*args)
|
33
|
+
self.relative_prefix + super
|
34
|
+
end
|
35
|
+
|
36
|
+
def element_path_with_relative_prefix(*args)
|
37
|
+
self.relative_prefix + element_path_without_relative_prefix(*args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def new_element_path_with_relative_prefix(*args)
|
41
|
+
self.relative_prefix + new_element_path_without_relative_prefix(*args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def collection_path_with_relative_prefix(*args)
|
45
|
+
self.relative_prefix + collection_path_without_relative_prefix(*args)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def custom_method_element_url(*args)
|
50
|
+
self.relative_prefix + super
|
51
|
+
end
|
52
|
+
|
53
|
+
def custom_method_new_element_url(*args)
|
54
|
+
self.relative_prefix + super
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/focus-utils.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_resource'
|
2
2
|
require 'yaml'
|
3
|
+
require 'ares/add_relative_prefix'
|
3
4
|
require 'ares/remove_format_extension'
|
4
5
|
require 'ares/add_api_key'
|
5
6
|
require 'ares/use_config_file'
|
@@ -7,4 +8,5 @@ require 'ares/use_config_file'
|
|
7
8
|
#ActiveResource::Base.include_format_in_path = false
|
8
9
|
ActiveResource::Base.send(:include, ActiveResource::Extend::RemoveExtension)
|
9
10
|
ActiveResource::Base.send(:include, ActiveResource::Extend::AuthWithApiKey)
|
11
|
+
ActiveResource::Base.send(:include, ActiveResource::Extend::AddRelativePrefix)
|
10
12
|
ActiveResource::Base.establish_site_connection
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: focus-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -35,6 +35,7 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- lib/ares/add_api_key.rb
|
38
|
+
- lib/ares/add_relative_prefix.rb
|
38
39
|
- lib/ares/remove_format_extension.rb
|
39
40
|
- lib/ares/use_config_file.rb
|
40
41
|
- lib/focus-utils.rb
|