Class: EgovUtils::Love
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- EgovUtils::Love
- Defined in:
- app/resources/egov_utils/love.rb
Direct Known Subclasses
Class Method Summary collapse
- .config ⇒ Object
-
.inherited(subclass) ⇒ Object
mocking.
- .mock! ⇒ Object
- .mock_subclass(subclass) ⇒ Object
- .mocked_classes ⇒ Object
- .where(clauses = {}) ⇒ Object
Class Method Details
.config ⇒ Object
45 46 47 48 |
# File 'app/resources/egov_utils/love.rb', line 45 def self.config file = Rails.root.join('config', 'config.yml') File.exist?(file) ? YAML.load_file(file) : {} end |
.inherited(subclass) ⇒ Object
mocking
62 63 64 |
# File 'app/resources/egov_utils/love.rb', line 62 def self.inherited(subclass) mock_subclass(subclass) if @mocking end |
.mock! ⇒ Object
70 71 72 73 74 75 |
# File 'app/resources/egov_utils/love.rb', line 70 def self.mock! @mocking = true EgovUtils::Love.subclasses.each do |cls| mock_subclass(cls) end end |
.mock_subclass(subclass) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'app/resources/egov_utils/love.rb', line 77 def self.mock_subclass(subclass) mock_cls = "#{subclass.name}Mock".safe_constantize return unless mock_cls mocked_classes[subclass.name] = subclass namespaces = subclass.name.split('::') namespace = (namespaces[0..-2].join('::').presence || 'Object').safe_constantize namespace.send(:remove_const, namespaces[-1]) namespace.const_set(namespaces[-1], mock_cls) end |
.mocked_classes ⇒ Object
66 67 68 |
# File 'app/resources/egov_utils/love.rb', line 66 def self.mocked_classes @mocked_classes ||= {} end |
.where(clauses = {}) ⇒ Object
54 55 56 57 |
# File 'app/resources/egov_utils/love.rb', line 54 def self.where(clauses = {}) raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash find(:all, params: {f: clauses}) end |