module Sumac::ExposedObject::IncludedClassMethods

Attributes

__child_accessor__[R]

Public Instance Methods

__exposed_methods__() click to toggle source
# File lib/sumac/exposed_object.rb, line 23
def __exposed_methods__
  @__exposed_methods__ ||= []
end
child_accessor(method_name = nil) click to toggle source
# File lib/sumac/exposed_object.rb, line 27
def child_accessor(method_name = nil)
  unless method_name.is_a?(Symbol) || method_name.is_a?(String)
    raise ArgumentError, "'child_accessor' expects a method name as a string for symbol"
  end
  @__child_accessor__ = method_name.to_s
end
expose(*method_names) click to toggle source
# File lib/sumac/exposed_object.rb, line 34
def expose(*method_names)
  raise ArgumentError, 'at least one argument expected' if method_names.empty?
  unless method_names.each { |method_name| method_name.is_a?(Symbol) || method_name.is_a?(String) }
    raise 'only symbols or strings expected'  
  end
  @__exposed_methods__ ||= []
  @__exposed_methods__.concat(method_names.map(&:to_s))
end
inherited(base) click to toggle source
# File lib/sumac/exposed_object.rb, line 16
def inherited(base)
  base.instance_variable_set(:@__exposed_methods__, @__exposed_methods__.dup)
  base.instance_variable_set(:@__child_accessor__, @__child_accessor__)
end