Module: Ruboty::TrustMe

Defined in:
lib/ruboty/trust_me.rb,
lib/ruboty/trust_me/version.rb,
lib/ruboty/trust_me/actions/trust.rb,
lib/ruboty/trust_me/actions/dont_trust.rb

Defined Under Namespace

Modules: Actions

Constant Summary collapse

NAMESPACE =
'trust_me'
VERSION =
"1.0.4"

Instance Method Summary collapse

Instance Method Details

#receive(attributes) ⇒ Object



8
9
10
11
12
# File 'lib/ruboty/trust_me.rb', line 8

def receive(attributes)
  if trust?(attributes[:from_name] || attributes[:from])
    super
  end
end

#trust?(from_name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ruboty/trust_me.rb', line 14

def trust?(from_name)
  trusted_names.include?(from_name) || trusted_names.empty? || from_name == name
end

#trusted_namesObject



18
19
20
# File 'lib/ruboty/trust_me.rb', line 18

def trusted_names
  brain.data[::Ruboty::TrustMe::NAMESPACE] ||= []
end