Class: ActionService::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_service/base.rb

Class Method Summary collapse

Class Method Details

.export(name, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/action_service/base.rb', line 14

def export(name, options={})
  validate_options([:expects, :returns, :expects_and_returns], options.keys)
  if options[:expects_and_returns]
    expects = options[:expects_and_returns]
    returns = options[:expects_and_returns]
  else
    expects = options[:expects]
    returns = options[:returns]
  end
  name = name.to_sym
  public_name = public_export_name(name)
  info = { :expects => expects, :returns => returns }
  write_inheritable_hash("action_service_exports", name => info)
  write_inheritable_hash("action_service_public_exports", public_name => name)
end

.exportsObject



50
51
52
# File 'lib/action_service/base.rb', line 50

def exports
  read_inheritable_attribute("action_service_exports") || {}
end

.has_export?(name) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/action_service/base.rb', line 30

def has_export?(name)
  exports.has_key?(name)
end

.has_public_export?(name) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/action_service/base.rb', line 34

def has_public_export?(name)
  public_exports.has_key?(name)
end

.internal_export_name(public_name) ⇒ Object



46
47
48
# File 'lib/action_service/base.rb', line 46

def internal_export_name(public_name)
  public_exports[public_name]
end

.public_export_name(export_name) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/action_service/base.rb', line 38

def public_export_name(export_name)
  if export_name_mangling
    Inflector.camelize(export_name.to_s)
  else
    export_name.to_s
  end
end