Class: DocomoNlu::Management::MultipartBase

Inherits:
Base
  • Object
show all
Defined in:
lib/docomo_nlu/management/multipart_base.rb

Direct Known Subclasses

Map, Set

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

check_response, headers, #id_from_response, instantiate_collection, instantiate_record, #login, #logout, #static_headers

Class Method Details

.create(file, prefix_options) ⇒ Object

Raises:

  • (ActiveResource::BadRequest)


17
18
19
20
21
22
# File 'lib/docomo_nlu/management/multipart_base.rb', line 17

def create(file, prefix_options)
  check_prefix_options(prefix_options)
  raise ActiveResource::BadRequest, "" unless file.instance_of?(File)

  upload(file, prefix_options)
end

.find(*arguments) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/docomo_nlu/management/multipart_base.rb', line 24

def find(*arguments)
  scope   = arguments.slice!(0)
  options = arguments.slice!(0) || {}

  prefix_options, = split_options(options[:params])
  check_prefix_options(prefix_options)

  case scope
  when :all then download(nil, prefix_options)
  else download(scope, prefix_options)
  end
end

.where(clauses = {}) ⇒ Object

Raises:

  • (ArgumentError)


37
38
39
40
41
42
# File 'lib/docomo_nlu/management/multipart_base.rb', line 37

def where(clauses = {})
  raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash

  category = clauses[:category]
  find(category, params: clauses)
end

Instance Method Details

#destroyObject



11
12
13
14
# File 'lib/docomo_nlu/management/multipart_base.rb', line 11

def destroy
  self.id = try(:category)
  super
end

#saveObject



7
8
9
# File 'lib/docomo_nlu/management/multipart_base.rb', line 7

def save
  self.class.create(attributes[:file], prefix_options)
end