Create a re-usable, predefined hash filter #532
-
Hi there, I've got a piece of data input that gets repeated around various commands. It's in the form of a Hash and always has the same structure. Is there recommended way to define the structure of my hash input once and reference it from any command? example: a data type representing a "quantity". a I'm wondering if I could do something as such, somehow: class OrderFood < ActiveInteraction::Base
string :name
quantity :qty # <-- quantity is a predefined hash filter
def execute
puts "ordering #{qty[:amount]} #{qty[:unit]} of #{name}"
end
end also I might want to nest this Thanks for the lovely library, you rock. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks! What you want can be done but it's not the easiest thing. The problem is there's no documentation for doing it and I haven't committed to a public interface for creating custom filters. It does seem like something that would be useful though. I'll think about what it would take to document it. In the meantime you'll have to dig a bit around in the existing filters. |
Beta Was this translation helpful? Give feedback.
Thanks!
What you want can be done but it's not the easiest thing. The problem is there's no documentation for doing it and I haven't committed to a public interface for creating custom filters. It does seem like something that would be useful though. I'll think about what it would take to document it. In the meantime you'll have to dig a bit around in the existing filters.