class Rogue::RogueObject

Special class that allows dot notation access to member values

eg. myobj = CustomStruct.new
eg. myobj.with_properties(id: 1, title: 'First Screen', click_action: 'click_to_web')
with this you can do:
myobj.title and get 'First Screen'

Public Instance Methods

method_missing(m, *args, &block) click to toggle source
# File lib/rogue.rb, line 26
def method_missing(m, *args, &block)
  raise ArgumentError.new "Method :#{m} not defined with arguments #{args}" unless @methods.include?(m)
  @methods[m].call(*args) if @methods.include?(m)
end
with_properties( args = Hash.new ) click to toggle source
# File lib/rogue.rb, line 14
def with_properties( args = Hash.new )
  @methods = {}
  args.each do |name,initial_value|
    if initial_value.is_a?(Proc)
      @methods[name] = initial_value
    else
      new_ostruct_member name
      send "#{name}=" , initial_value
    end
  end
  self
end