Module: EZApi::DSL::ClassMethods

Defined in:
lib/ezapi/dsl.rb

Instance Method Summary collapse

Instance Method Details

#actions(actions) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/ezapi/dsl.rb', line 12

def actions(actions)
  actions.each do |action|
    include_action(action)
  end

  if (actions & [:create, :update]).any? && !actions.include?(:save)
    include_action(:save)
  end
end

#api_pathObject



27
28
29
30
# File 'lib/ezapi/dsl.rb', line 27

def api_path
  path = self.name.demodulize.underscore.pluralize
  "#{CGI.escape(path)}"
end

#clientObject



22
23
24
25
# File 'lib/ezapi/dsl.rb', line 22

def client
  client_name = self.name.deconstantize
  @client ||= !client_name.empty? ? client_name.constantize : EZApi::Client
end

#path(url) ⇒ Object



8
9
10
# File 'lib/ezapi/dsl.rb', line 8

def path(url)
  define_singleton_method(:api_path) { url }
end