Module: Dashamail

Defined in:
lib/dashamail.rb,
lib/dashamail/error.rb,
lib/dashamail/request.rb,
lib/dashamail/version.rb,
lib/dashamail/response.rb,
lib/dashamail/api_request.rb,
lib/generators/dashamail/install/install_generator.rb

Defined Under Namespace

Classes: APIRequest, DynamicSetting, Error, InstallGenerator, Request, Response

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.add_reader(name) ⇒ Object



22
23
24
25
26
# File 'lib/dashamail.rb', line 22

def add_reader(name)
  define_singleton_method(name) do |*args|
    send("#{name}_setting").value(*args)
  end
end

.add_writer(name, type) ⇒ Object



28
29
30
31
32
# File 'lib/dashamail.rb', line 28

def add_writer(name, type)
  define_singleton_method("#{name}=") do |value|
    send("#{name}_setting=", DynamicSetting.build(value, type))
  end
end

.register(name, value, type = nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/dashamail.rb', line 14

def register(name, value, type = nil)
  cattr_accessor "#{name}_setting".to_sym

  add_reader(name)
  add_writer(name, type)
  send "#{name}=", value
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Dashamail)

    the object that the method was called on



10
11
12
# File 'lib/dashamail.rb', line 10

def setup
  yield self
end