Module: Conversational::Conversation::ClassMethods
- Defined in:
- lib/conversational/conversation.rb
Instance Method Summary collapse
- #blank_topic_subclass(value) ⇒ Object
- #class_suffix(value) ⇒ Object
-
#exclude(classes) ⇒ Object
No problem here you will work with MonkeyConversation directly.
- #unknown_topic_subclass(value) ⇒ Object
Instance Method Details
#blank_topic_subclass(value) ⇒ Object
85 86 87 |
# File 'lib/conversational/conversation.rb', line 85 def blank_topic_subclass(value) Conversational::Conversation.blank_topic_subclass = Conversational::Conversation.stringify(value) end |
#class_suffix(value) ⇒ Object
89 90 91 |
# File 'lib/conversational/conversation.rb', line 89 def class_suffix(value) Conversational::Conversation.class_suffix = Conversational::Conversation.stringify(value) end |
#exclude(classes) ⇒ Object
No problem here you will work with MonkeyConversation directly. But what if the user sends in a message like “abstract”? <tt>
message = IncomingTextMessage.last
topic = message.text.split(" ").first
=> "abstract"
number = message.number
=> "123456789"
conversation = Conversation.new(:with => number, :topic => topic).details
=> #<AbstractConversation topic: "abstract", with: "123456789">
</tt> Now you’re are about to work with AbstractConversation directly which is not what you want. Let’s fix it <tt>
# config/initializers/conversation.rb
Conversation.exclude AbstractConversation
Conversation.unknown_topic_subclass = UnkownTopicConversation
</tt>
<tt>
message = IncomingTextMessage.last
topic = message.text.split(" ").first
=> "abstract"
number = message.number
=> "123456789"
conversation = Conversation.new(:with => number, :topic => topic).details
=> #<UnknownTopicConversation topic: "abstract", with: "123456789">
</tt>
Conversation.exclude
accepts the following
-
Class:
Conversation.exclude AbstractConversation
-
Array:
Conversation.exclude [AbstractConversation, OtherConversation]
-
Symbol:
Conversation.exclude :abstract_conversation
-
String:
Conversation.exclude "abstract_conversation"
-
Regexp:
Conversation.exclude /abstract/i
169 170 171 |
# File 'lib/conversational/conversation.rb', line 169 def exclude(classes) Conversational::Conversation.exclude(classes) end |
#unknown_topic_subclass(value) ⇒ Object
81 82 83 |
# File 'lib/conversational/conversation.rb', line 81 def unknown_topic_subclass(value) Conversational::Conversation.unknown_topic_subclass = Conversational::Conversation.stringify(value) end |