Class: LucidWorks::Schema::BooleanAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/lucid_works/schema/boolean_attribute.rb

Constant Summary

Constants inherited from Attribute

Attribute::ATTRIBUTES_TYPES, Attribute::RESERVED_ATTRIBUTE_NAMES

Instance Attribute Summary

Attributes inherited from Attribute

#name, #origin, #schema, #values

Instance Method Summary collapse

Methods inherited from Attribute

#encode_and_insert, factory, #initialize, #nil_when_blank?, #omit_during_update?, #omit_when_blank?, sanitize_name, #to_select

Constructor Details

This class inherits a constructor from LucidWorks::Schema::Attribute

Instance Method Details

#create_accessors_for_attribute(klass) ⇒ Object

:nodoc:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lucid_works/schema/boolean_attribute.rb', line 10

def create_accessors_for_attribute(klass) # :nodoc:
  super

  klass.class_eval "    def \#{name}?                                            # def foo?\n      @attributes[:\#{name}]                                 #   @attributes[:foo]\n    end                                                     # end\n\n    def \#{name}=(new_value)                                 # def foo=(new_value)\n      begin                                                 #   begin\n        @attributes[:\#{name}] = to_bool(new_value)          #     @attributes[:foo] = to_bool(new_value)\n      rescue                                                #   rescue\n        raise \"Expected \#{name} to take a boolean\"+         #     raise \"Expected <some_bool> to take a boolean\n              \" value, but '\\#\\{new_value}' is ambiguous\"   #           \" value, but 'frozbot' is ambiguous\"\n      end                                                   #   end\n    end                                                     # end\n  EOF\nend\n", __FILE__, __LINE__+1

#human_value(value) ⇒ Object



29
30
31
# File 'lib/lucid_works/schema/boolean_attribute.rb', line 29

def human_value(value)
  (!!value).to_yesno
end

#typeObject



6
7
8
# File 'lib/lucid_works/schema/boolean_attribute.rb', line 6

def type
  :boolean
end