Class: Audrey::Object::Custom::Field
- Inherits:
-
Object
- Object
- Audrey::Object::Custom::Field
- Defined in:
- lib/audrey.rb
Overview
Audrey::Object::Custom::Field
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auto ⇒ Object
Returns the value of attribute auto.
-
#clss ⇒ Object
Returns the value of attribute clss.
-
#graph ⇒ Object
Returns the value of attribute graph.
-
#name ⇒ Object
Returns the value of attribute name.
-
#publish ⇒ Object
Returns the value of attribute publish.
-
#read ⇒ Object
Returns the value of attribute read.
-
#required ⇒ Object
Returns the value of attribute required.
-
#write ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
-
#add_to_class(tgt) ⇒ Object
————————————————————————— add_to_class.
-
#auto_add(object) ⇒ Object
————————————————————————— auto_add.
-
#base_checks(*opts) ⇒ Object
————————————————————————— base_checks.
-
#has_checks? ⇒ Boolean
————————————————————————— has_checks?.
-
#initialize(p_name) ⇒ Field
constructor
————————————————————————— initialize.
-
#normalize(val) ⇒ Object
————————————————————————— normalize.
Constructor Details
#initialize(p_name) ⇒ Field
initialize
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 |
# File 'lib/audrey.rb', line 2057 def initialize(p_name) @name = p_name @read = true @write = true @clss = nil @auto = false @publish = false @graph = false # normalize name @name = @name.strip @name = @name.gsub(/\s+/mu, ' ') end |
Instance Attribute Details
#auto ⇒ Object
Returns the value of attribute auto.
2049 2050 2051 |
# File 'lib/audrey.rb', line 2049 def auto @auto end |
#clss ⇒ Object
Returns the value of attribute clss.
2048 2049 2050 |
# File 'lib/audrey.rb', line 2048 def clss @clss end |
#graph ⇒ Object
Returns the value of attribute graph.
2051 2052 2053 |
# File 'lib/audrey.rb', line 2051 def graph @graph end |
#name ⇒ Object
Returns the value of attribute name.
2045 2046 2047 |
# File 'lib/audrey.rb', line 2045 def name @name end |
#publish ⇒ Object
Returns the value of attribute publish.
2050 2051 2052 |
# File 'lib/audrey.rb', line 2050 def publish @publish end |
#read ⇒ Object
Returns the value of attribute read.
2046 2047 2048 |
# File 'lib/audrey.rb', line 2046 def read @read end |
#required ⇒ Object
Returns the value of attribute required.
2052 2053 2054 |
# File 'lib/audrey.rb', line 2052 def required @required end |
#write ⇒ Object
Returns the value of attribute write.
2047 2048 2049 |
# File 'lib/audrey.rb', line 2047 def write @write end |
Instance Method Details
#add_to_class(tgt) ⇒ Object
add_to_class
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 |
# File 'lib/audrey.rb', line 2078 def add_to_class(tgt) # $tm.hrm # Ruby doesn't like it if we use an @ variable in the method definition # of another class. nme = @name.dup # read if @read tgt.define_method(nme) do return @node[nme] end end # write if @write # reference self inside the method for assigning the instance # variable me = self # definew method tgt.define_method("#{nme}=") do |val| val = me.normalize(val) return @node[nme] = val end end end |
#auto_add(object) ⇒ Object
auto_add
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 |
# File 'lib/audrey.rb', line 2113 def auto_add(object) # early exit @auto or return # get audrey node node = object.audrey # init new_val = nil # add to node if Audrey::Object::Custom.descendant?(@auto) new_val = @auto.new('accessor'=>node.db) elsif @auto.is_a?(Proc) new_val = @auto.call(object) end # set new value node[@name] = new_val end |
#base_checks(*opts) ⇒ Object
base_checks
2163 2164 |
# File 'lib/audrey.rb', line 2163 def base_checks(*opts) end |
#has_checks? ⇒ Boolean
has_checks?
2152 2153 2154 |
# File 'lib/audrey.rb', line 2152 def has_checks? return false end |
#normalize(val) ⇒ Object
normalize
2141 2142 2143 |
# File 'lib/audrey.rb', line 2141 def normalize(val) return val end |