Module: JsonApi::ClassMethods

Defined in:
lib/json-api.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/json-api.rb', line 128

def method_missing(name, *args)
  if instance_methods.include? name
    new.send(name, *args)
  else
    super
  end
end

Instance Method Details

#routes(routes) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/json-api.rb', line 113

def routes(routes)
  routes.each do |name, path|
    define_method("#{name}_path") do |*args|
      case path
      when String
        path
      when Symbol
        send("#{path}_path", *args)
      when Proc
        path.call(*args)
      end
    end
  end
end