Module: Flexirest::Mapping::ClassMethods
- Defined in:
- lib/flexirest/mapping.rb
Instance Method Summary collapse
- #_call(name, options) ⇒ Object
- #_calls ⇒ Object
- #_map_call(name, details) ⇒ Object
- #_mapped_method(name) ⇒ Object
- #delete(name, url, options = {}) ⇒ Object
- #get(name, url, options = {}) ⇒ Object
- #inherited(subclass) ⇒ Object
- #patch(name, url, options = {}) ⇒ Object
- #post(name, url, options = {}) ⇒ Object
- #put(name, url, options = {}) ⇒ Object
Instance Method Details
#_call(name, options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/flexirest/mapping.rb', line 35 def _call(name, ) mapped = _calls[name] lazy_forced = false if mapped.nil? && name.to_s[/^lazy_/] mapped = _calls[name.to_s.gsub(/^lazy_/, '').to_sym] lazy_forced = true end request = Request.new(mapped, self, ) if lazy_load? || lazy_forced Flexirest::LazyLoader.new(request) else request.call end end |
#_calls ⇒ Object
50 51 52 |
# File 'lib/flexirest/mapping.rb', line 50 def _calls @_calls end |
#_map_call(name, details) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/flexirest/mapping.rb', line 24 def _map_call(name, details) _calls[name] = {name:name}.merge(details) _calls["lazy_#{name}".to_sym] = {name:name}.merge(details) (class << self; self; end).send(:define_method, name) do |={}| _call(name, ) end (class << self; self; end).send(:define_method, "lazy_#{name}".to_sym) do |={}| _call("lazy_#{name}", ) end end |
#_mapped_method(name) ⇒ Object
54 55 56 |
# File 'lib/flexirest/mapping.rb', line 54 def _mapped_method(name) _calls[name] end |
#delete(name, url, options = {}) ⇒ Object
16 17 18 |
# File 'lib/flexirest/mapping.rb', line 16 def delete(name, url, = {}) _map_call(name, url:url, method: :delete, options:) end |
#get(name, url, options = {}) ⇒ Object
4 5 6 |
# File 'lib/flexirest/mapping.rb', line 4 def get(name, url, = {}) _map_call(name, url:url, method: :get, options:) end |
#inherited(subclass) ⇒ Object
58 59 60 |
# File 'lib/flexirest/mapping.rb', line 58 def inherited(subclass) subclass.instance_variable_set(:@_calls, {}) end |
#patch(name, url, options = {}) ⇒ Object
20 21 22 |
# File 'lib/flexirest/mapping.rb', line 20 def patch(name, url, = {}) _map_call(name, url:url, method: :patch, options:) end |
#post(name, url, options = {}) ⇒ Object
12 13 14 |
# File 'lib/flexirest/mapping.rb', line 12 def post(name, url, = {}) _map_call(name, url:url, method: :post, options:) end |
#put(name, url, options = {}) ⇒ Object
8 9 10 |
# File 'lib/flexirest/mapping.rb', line 8 def put(name, url, = {}) _map_call(name, url:url, method: :put, options:) end |