pakyow-presenter/lib/presenter/binder.rb in pakyow-presenter-0.7.2 vs pakyow-presenter/lib/presenter/binder.rb in pakyow-presenter-0.8rc1
- old
+ new
@@ -15,16 +15,19 @@
self.options = {} unless self.options
self.options[args[0]] = args[1]
end
end
- attr_accessor :bindable, :object
+ attr_accessor :bindable
- def initialize(bindable, object)
+ def initialize(bindable)
self.bindable = bindable
- self.object = object
end
+
+ def value_for_prop(prop)
+ self.class.method_defined?(prop) ? self.send(prop) : bindable[prop]
+ end
def fetch_options_for(attribute)
if self.class.options
if options = self.class.options[attribute]
unless options.is_a?(Array) || options.is_a?(Hash)
@@ -32,29 +35,9 @@
end
return options
end
end
- end
-
- def action
- unless routes = Pakyow.app.restful_routes[bindable.class.name.to_sym]
- Log.warn "Attempting to bind object to #{bindable.class.name.downcase}[action] but could not find restful routes for #{bindable.class.name}."
- return {}
- end
-
- if id = bindable.id
- self.object.add_child('<input type="hidden" name="_method" value="put">')
-
-
- action = routes[:update].gsub(':id', id.to_s)
- method = "post"
- else
- action = routes[:create]
- method = "post"
- end
-
- return { :action => File.join('/', action), :method => method }
end
end
end
end