Parent

Monkeybars::BasicPropertyMapping

Public Instance Methods

model_from_view(view, model) click to toggle source
# File lib/monkeybars/view_mapping.rb, line 172
def model_from_view(view, model)
  begin
    instance_eval("model.#{@model_property} = view.#{@view_property}", __FILE__, __LINE__)
  rescue NoMethodError
    raise InvalidMappingError, "Either model.#{@model_property} or self.#{@view_property} in #{view.class} is not valid."
  rescue TypeError => e
    raise InvalidMappingError, "Invalid types when assigning from model.#{@model_property} to self.#{@view_property}, #{e.message} in #{view.class}"
  rescue SyntaxError, Exception => e
    raise InvalidMappingError, "Error while trying to map for #{view.class}: #{to_s}\n#{e.class} - #{e}"
  end
end
model_to_view(view, model) click to toggle source
# File lib/monkeybars/view_mapping.rb, line 146
def model_to_view(view, model)
  begin
    instance_eval("view.#{@view_property} = model.#{@model_property}", __FILE__, __LINE__)
  rescue NoMethodError
    raise InvalidMappingError, "Either model.#{@model_property} or self.#{@view_property} in #{view.class} is not valid."
  rescue TypeError => e
    raise InvalidMappingError, "Invalid types when assigning from model.#{@model_property} to self.#{@view_property}, #{e.message} in #{view.class}"
  rescue Monkeybars::UndefinedComponentError
    raise InvalidMappingError, "The view property #{@view_property} was not found on view #{view.class}"
  rescue SyntaxError, Exception => e
    raise InvalidMappingError, "Error while trying to map for #{view.class}: #{to_s}\n#{e.class} - #{e}"
  end
end
to_s() click to toggle source
# File lib/monkeybars/view_mapping.rb, line 140
def to_s
  model_or_transfer_key = model_mapping? ? ':model' : ':transfer'
  model_or_transfer_property = model_mapping? ? @model_property : @transfer_property
  ":view => #{@view_property.inspect}, #{model_or_transfer_key} => #{model_or_transfer_property.inspect}"
end
transfer_from_view(view, transfer) click to toggle source
# File lib/monkeybars/view_mapping.rb, line 184
def transfer_from_view(view, transfer)
  begin
    instance_eval("transfer[#{@transfer_property.inspect}] = view.#{@view_property}", __FILE__, __LINE__)
  rescue NoMethodError
    raise InvalidMappingError, "Either transfer[#{@transfer_property.inspect}] or self.#{@view_property} in #{view.class} is not valid."
  rescue TypeError => e
    raise InvalidMappingError, "Invalid types when assigning from transfer[#{@transfer_property.inspect}] to self.#{@view_property}, #{e.message} in #{view.class}"
  rescue SyntaxError, Exception => e
    raise InvalidMappingError, "Error while trying to map for #{view.class}: #{to_s}\n#{e.class} - #{e}"
  end
end
transfer_to_view(view, transfer) click to toggle source
# File lib/monkeybars/view_mapping.rb, line 160
def transfer_to_view(view, transfer)
  begin
    instance_eval("view.#{@view_property} = transfer[#{@transfer_property.inspect}]", __FILE__, __LINE__)
  rescue NoMethodError
    raise InvalidMappingError, "Either transfer[#{@transfer_property.inspect}] or self.#{@view_property} in #{view.class} is not valid."
  rescue TypeError => e
    raise InvalidMappingError, "Invalid types when assigning from transfer[#{@transfer_property.inspect}] to self.#{@view_property}, #{e.class}: #{e.message} in #{view.class}"
  rescue SyntaxError, Exception => e
    raise InvalidMappingError, "Error while trying to map for #{view.class}: #{to_s}\n#{e.class} - #{e}"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.