Sha256: c088cadddfabf207baeaccedda0125695b557dea2608ee95301c748d9b9cfb0e
Contents?: true
Size: 957 Bytes
Versions: 3
Compression:
Stored size: 957 Bytes
Contents
# encoding: utf-8 module Assertion # Collection of DSLs for various modules and classes # module DSL # Allows adding aliases to `#object` method. # module Attribute # Adds alias to the [#object] method # # @param [#to_sym] name # # @return [undefined] # # @raise [NameError] # When a given name is either used by instance methods, # or reserved by the `#state` method to be implemented later. # def attribute(name) __check_attribute__(name) alias_method name, :object end # @private def self.extended(klass) klass.__send__ :attr_reader, :object end private def __check_attribute__(key) return unless (instance_methods << :state).include? key.to_sym fail NameError.new "#{self}##{key} is already defined" end end # module Attribute end # module DSL end # module Assertion
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
assertion-0.2.3 | lib/assertion/dsl/attribute.rb |
assertion-0.2.2 | lib/assertion/dsl/attribute.rb |
assertion-0.2.1 | lib/assertion/dsl/attribute.rb |