Clients should not be forced to depend upon interfaces that they don't use. - Robert C. Martin
The Dependency Inversion Principle has to do with high-level (think business logic) objects not depending on low-level (think database querying and IO) implementation details. This can be achieved with duck typing and the Dependency Inversion Principle. Often this pattern is used to achieve the Open/Closed Principle...
define_method("authenticate_#{attribute}") do |unencrypted_password| attribute_digest = public_send("#{attribute}_digest") BCrypt::Password.new(attribute_digest).is_password?(unencrypted_password) && self end alias_method :authenticate, :authenticate_password if attribute == :password
<%= form.file_field :media, direct_upload: true, accept: 'audio/mpeg' %>