Sha256: cbca9831615569d693c7d63c57fcf33f66e38e3bc94639eb978d06c8a0e46457
Contents?: true
Size: 903 Bytes
Versions: 1
Compression:
Stored size: 903 Bytes
Contents
require 'active_support' require 'active_support/all' class ConcernBuilder require 'concern_builder/version' require 'concern_builder/options_parser' include OptionsParser attr_reader :attr_names, :methods_def def initialize(attr_names, instance, options) @attr_names = attr_names @instance = instance @options = options @methods_def = [] init end def build methods_def.each do |method_def| @instance.module_eval(method_def, __FILE__, __LINE__ + 1) end end private def add_method(name, code = nil, &block) if code.is_a?(String) add_code_method(name, code) else add_block_method(name, block) end end def add_block_method(name, block) @instance.send(:define_method, name, block) end def add_code_method(name, code) @methods_def << <<-CODE def #{name} #{code} end CODE end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
concern_builder-0.0.1 | lib/concern_builder.rb |