Skip to content

似たようなメソッドの定義 #74

@kzytateishi

Description

@kzytateishi

似たようなメソッドを増やしていくのはどうなの...?

def fax?
  self.code == "fax"
end

def tel?
  self.code == "tel"
end

こっちの方がいい?

# fax?  tel?
self.pluck(:code).each do |code|
  define_method("#{code}?") do
    self.code == code
  end
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions