Question: I’m using Rails 4.2.7 with Nokogiri. How do I create a new Nokogiri node to add to my document? I thought I could do this

```
general = doc.xpath("//lomimscc:general")
title = Nokogiri::XML::Node.new "lomimscc:title"
string = Nokogiri::XML::Node.new "lomimscc:string"
string.content = scenario.title
string.language = 'en' 
title << string 
general << title 

```

but I’m getting the error

```
ArgumentError: wrong number of arguments (given 1, expected 2+)
    from /Users/davea/Documents/workspace/sims/app/helpers/myproject_helper.rb:73:in `new'
    from /Users/davea/Documents/workspace/sims/app/helpers/myproject_helper.rb:73:in `set_manifest_title'
    from /Users/davea/Documents/workspace/sims/app/helpers/myproject_helper.rb:59:in `generate_manifest_file

```

Answer: 
you can't do that in an interface. What you would do is flip the logic upside down, and use the template pattern. Have one base method that defined the 'algorithm' that needs to happen, and defer points that need to be unique to subclasses:

```
public abstract class SenderBase
{
    public void Send()
    {
        ValidateContent();
        CustomStuff();
    }

    protected abstract void CustomStuff();
}

public sealed class EmailReportSender : SenderBase
{
    protected override void CustomStuff()
    {

    }
}
public sealed class IPhoneNotificationReportSender : SenderBase
{
    protected override void CustomStuff()
    {

    }
}

```
This sounds like a job for unit testing. Your compiler isn't going to enforce it for you, but if the rule exists, then it should be tested accordingly. The below uses Moq.

```
[TestFixture]
public class EmailReportSenderTests
{
    [Test]
    public void EmailReportSender_Send_CallsValidateContent()
    {
        var mock = new Mock<ISender>();
        mock.Setup(m => m.Send()).Verifiable();

        var sender = new EmailReportSender(mock.Object);
        sender.Send();

        mock.Verify(m => m.ValidateContent());
    }
}

```

I haven't tried that snippet, so it may have typos, but you get the idea.