File: param.rb

package info (click to toggle)
ruby-morpher 0.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: ruby: 2,366; makefile: 4
file content (54 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Morpher
  class Evaluator
    class Transformer
      class Domain < self

        # Domain specific transformer parameter
        class Param
          include Adamantium, Concord::Public.new(:model, :attribute_names)

          # Return attributes
          #
          # @return [Enumerable<Attribute>]
          #
          # @api private
          #
          def attributes
            attribute_names.map(&Attribute.method(:new))
          end
          memoize :attributes

          # Attribute on a domain transformer param
          class Attribute
            include Adamantium, Concord::Public.new(:name)

            # Return instance variable name
            #
            # @return [Symbol]
            #
            # @api private
            #
            def ivar_name
              :"@#{name}"
            end
            memoize :ivar_name

            # Return writer name
            #
            # @return [Symbol]
            #
            # @api private
            #
            def writer
              :"#{name}="
            end
            memoize :writer

          end # Attribute

        end # Param

      end # Domain
    end # Transformer
  end # Evaluator
end # Morpher