Sha256: 2c4761593908c3a7d1320c740ab77ab5cad7098c08307ad57498b51b638d5d26
Contents?: true
Size: 819 Bytes
Versions: 4
Compression:
Stored size: 819 Bytes
Contents
module Pakyow module Presenter class BindingEval include Pakyow::Helpers attr_reader :context, :bindable def initialize(prop, bindable, context) @parts = {} @prop = prop @bindable = bindable @context = context end def value if bindable.is_a?(Hash) bindable[@prop] elsif bindable.respond_to?(@prop) bindable.send(@prop) end end def eval(&block) ret = instance_exec(value, bindable, context, &block) if ret.respond_to?(:to_hash) @parts.merge!(ret.to_hash) end @parts.empty? ? ret : @parts end def part(name, &block) @parts[name.to_sym] = block nil # Return nil so #part return value is ignored end end end end
Version data entries
4 entries across 4 versions & 1 rubygems