Module: ActiveResource::Extend::Singleton::ClassMethods

Defined in:
lib/ares/add_singleton.rb

Instance Method Summary collapse

Instance Method Details

#collection_name_with_singletonObject



41
42
43
44
45
46
47
# File 'lib/ares/add_singleton.rb', line 41

def collection_name_with_singleton
  if singleton
    element_name
  else
    collection_name_without_singleton
  end
end

#find_one_with_singleton(options) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/ares/add_singleton.rb', line 31

def find_one_with_singleton(options)
  found_object = find_one_without_singleton(options)
  if !found_object && singleton
    prefix_options, query_options = split_options(options[:params])
    path = element_path(nil, prefix_options, query_options)
    found_object = instantiate_record(format.decode(connection.get(path, headers).body), prefix_options)
  end
  found_object
end

#singletonObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/ares/add_singleton.rb', line 16

def singleton
  # Not using superclass_delegating_reader. See +site+ for explanation
  if defined?(@singleton)
    @singleton
  elsif superclass != Object && superclass.singleton
    superclass.singleton.dup.freeze
  else
    @singleton = false
  end
end

#singleton=(singleton) ⇒ Object



27
28
29
# File 'lib/ares/add_singleton.rb', line 27

def singleton=(singleton)
  @singleton = singleton
end