Method: Psapi::API_Object.define_all_with

Defined in:
lib/psapi/api_object.rb

.define_all_with(method_name) ⇒ Object

APIオブジェクトクラスに all クラスメソッドを追加する



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/psapi/api_object.rb', line 33

def define_all_with(method_name)
  object_klass = self
  self.singleton_class.class_eval do
    define_method(:all) do
      __send__(method_name).map do |item|
        object_klass.new(item)
      end
    end

  end
end