Sha256: ba059528ba853bc8b9d6b4e043f45fbc3aea7d2cc290982f7d8fe6401218a120
Contents?: true
Size: 952 Bytes
Versions: 3
Compression:
Stored size: 952 Bytes
Contents
module Danica module Expressable extend ::ActiveSupport::Concern included do include VariablesHolder class << self def built_with(block_name) self.send(:delegate, :to_f, to: block_name) self.send(:define_singleton_method, :build) do |*vars, &block| Class.new(self) do variables(*vars) private module_eval("define_method :#{block_name} do @#{block_name} ||= instance_eval(&block) if block end") end end self.send(:define_singleton_method, :create) do |*vars, &block| build(*vars, &block).new end end end end def initialize(*args) options = args.extract_options! attributes = { variables: args.flatten }.merge(options) attributes.each do |key, value| self.public_send("#{key}=", value) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
danica-2.6.0 | lib/danica/expressable.rb |
danica-2.5.1 | lib/danica/expressable.rb |
danica-2.5.0 | lib/danica/expressable.rb |